Re: [PATCH] ext4: fix quota accounting in case of fallocate

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: dmonakhov
Date: Tuesday, March 30, 2010 - 9:51 pm

"Aneesh Kumar K. V" <aneesh.kumar@linux.vnet.ibm.com> writes:

Yes. remove all, but minus already allocated_metadata, which was
accounted in to metadata reservation.
Just try an example:
reserve_space (inode, lblock := 1024 ) {
   md_needed = ext4_calc_metadata_amount(inode, lblock) (let it be '2')
   dquot_reserve_block(inode, md_needed + 1) /* '3' i.e blocks  reserved*/
   /* If this is first reservation for this inode then
    dq_rsv = inode->i_reserved_data_blocks + inode->i_reserved_meta_block
   */
}
Later called from fallocate
update_rerved_space(inode, used:=1, claim :=0) {
  /* Let i_allocatd_meta_data is '1' (as it so in most cases)  */
  ei->i_reserved_data_blocks -= used;  /* 1 - 1 => 0 */
  used += ei->i_allocated_meta_blocks; /* 1 + 1 => 2 */
  ei->i_reserved_meta_blocks -= ei->i_allocated_meta_blocks /* 2 - 1 => 1 */
  allocated_meta_blocks = ei->i_allocated_meta_blocks; /*  1 */
  ei->i_allocated_meta_blocks = 0;

  if (ei->i_reserved_data_blocks == 0) /* True in our case */
     mdb_free = ei->i_reserved_meta_blocks; /* mbd_free == 1*/

  if (allocated_meta_blocks)
         dquot_claim_block(inode, allocated_meta_blocks); /* claim '1' block*/
  dquot_release_reservation_block(inode, mdb_free + used); /* free (1 + 2) */

  /* So we reserved:
     dq_rsv = i_reserved_data_blocks + i_reserved_meta_block ( 3 blocks)
     But during update we claim + free:
          i_allocated_meta_data+(i_reserved_data_block+i_reserved_meta_data)
          (4 blocks).
          Which result in incorrect dquota reservation accounting(it
          goes negative)
  */

Initially i've found the issue by executing fsstress with falloc support.
It takes enouth process to catch writepage/fallocate overlapping.
xfstests-dev/ltp/xfsfsstress -p100 -n99999999

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] ext4: fix quota accounting in case of fallocate, Dmitry Monakhov, (Tue Mar 30, 7:24 am)
Re: [PATCH] ext4: fix quota accounting in case of fallocate, Dmitry Monakhov, (Tue Mar 30, 7:27 am)
Re: [PATCH] ext4: fix quota accounting in case of fallocate, Aneesh Kumar K. V, (Tue Mar 30, 11:08 am)
Re: [PATCH] ext4: fix quota accounting in case of fallocate, dmonakhov, (Tue Mar 30, 9:51 pm)