dquot: cleanup space allocation / freeing routines

Get rid of the alloc_space, free_space, reserve_space, claim_space and
release_rsv dquot operations - they are always called from the filesystem
and if a filesystem really needs their own (which none currently does)
it can just call into it's own routine directly.

Move shared logic into the common __dquot_alloc_space,
dquot_claim_space_nodirty and __dquot_free_space low-level methods,
and rationalize the wrappers around it to move as much as possible
code into the common block for CONFIG_QUOTA vs not.  Also rename
all these helpers to be named dquot_* instead of vfs_dq_*.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Christoph Hellwig
2010-03-03 09:05:00 -05:00
committed by Jan Kara
parent 49792c806d
commit 5dd4056db8
29 changed files with 273 additions and 398 deletions
+1 -5
View File
@@ -462,9 +462,7 @@ in sys_read() and friends.
prototypes: prototypes:
int (*initialize) (struct inode *, int); int (*initialize) (struct inode *, int);
int (*drop) (struct inode *); int (*drop) (struct inode *);
int (*alloc_space) (struct inode *, qsize_t, int);
int (*alloc_inode) (const struct inode *, unsigned long); int (*alloc_inode) (const struct inode *, unsigned long);
int (*free_space) (struct inode *, qsize_t);
int (*free_inode) (const struct inode *, unsigned long); int (*free_inode) (const struct inode *, unsigned long);
int (*transfer) (struct inode *, struct iattr *); int (*transfer) (struct inode *, struct iattr *);
int (*write_dquot) (struct dquot *); int (*write_dquot) (struct dquot *);
@@ -481,9 +479,7 @@ What filesystem should expect from the generic quota functions:
FS recursion Held locks when called FS recursion Held locks when called
initialize: yes maybe dqonoff_sem initialize: yes maybe dqonoff_sem
drop: yes - drop: yes -
alloc_space: ->mark_dirty() -
alloc_inode: ->mark_dirty() - alloc_inode: ->mark_dirty() -
free_space: ->mark_dirty() -
free_inode: ->mark_dirty() - free_inode: ->mark_dirty() -
transfer: yes - transfer: yes -
write_dquot: yes dqonoff_sem or dqptr_sem write_dquot: yes dqonoff_sem or dqptr_sem
@@ -495,7 +491,7 @@ write_info: yes dqonoff_sem
FS recursion means calling ->quota_read() and ->quota_write() from superblock FS recursion means calling ->quota_read() and ->quota_write() from superblock
operations. operations.
->alloc_space(), ->alloc_inode(), ->free_space(), ->free_inode() are called ->alloc_inode(), ->free_inode() are called
only directly by the filesystem and do not call any fs functions only only directly by the filesystem and do not call any fs functions only
the ->mark_dirty() operation. the ->mark_dirty() operation.
+7 -5
View File
@@ -570,7 +570,7 @@ do_more:
error_return: error_return:
brelse(bitmap_bh); brelse(bitmap_bh);
release_blocks(sb, freed); release_blocks(sb, freed);
vfs_dq_free_block(inode, freed); dquot_free_block(inode, freed);
} }
/** /**
@@ -1236,6 +1236,7 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal,
unsigned short windowsz = 0; unsigned short windowsz = 0;
unsigned long ngroups; unsigned long ngroups;
unsigned long num = *count; unsigned long num = *count;
int ret;
*errp = -ENOSPC; *errp = -ENOSPC;
sb = inode->i_sb; sb = inode->i_sb;
@@ -1247,8 +1248,9 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal,
/* /*
* Check quota for allocation of this block. * Check quota for allocation of this block.
*/ */
if (vfs_dq_alloc_block(inode, num)) { ret = dquot_alloc_block(inode, num);
*errp = -EDQUOT; if (ret) {
*errp = ret;
return 0; return 0;
} }
@@ -1409,7 +1411,7 @@ allocated:
*errp = 0; *errp = 0;
brelse(bitmap_bh); brelse(bitmap_bh);
vfs_dq_free_block(inode, *count-num); dquot_free_block(inode, *count-num);
*count = num; *count = num;
return ret_block; return ret_block;
@@ -1420,7 +1422,7 @@ out:
* Undo the block allocation * Undo the block allocation
*/ */
if (!performed_allocation) if (!performed_allocation)
vfs_dq_free_block(inode, *count); dquot_free_block(inode, *count);
brelse(bitmap_bh); brelse(bitmap_bh);
return 0; return 0;
} }
+5 -5
View File
@@ -644,8 +644,8 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
the inode. */ the inode. */
ea_bdebug(new_bh, "reusing block"); ea_bdebug(new_bh, "reusing block");
error = -EDQUOT; error = dquot_alloc_block(inode, 1);
if (vfs_dq_alloc_block(inode, 1)) { if (error) {
unlock_buffer(new_bh); unlock_buffer(new_bh);
goto cleanup; goto cleanup;
} }
@@ -702,7 +702,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
* as if nothing happened and cleanup the unused block */ * as if nothing happened and cleanup the unused block */
if (error && error != -ENOSPC) { if (error && error != -ENOSPC) {
if (new_bh && new_bh != old_bh) if (new_bh && new_bh != old_bh)
vfs_dq_free_block(inode, 1); dquot_free_block(inode, 1);
goto cleanup; goto cleanup;
} }
} else } else
@@ -734,7 +734,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
le32_add_cpu(&HDR(old_bh)->h_refcount, -1); le32_add_cpu(&HDR(old_bh)->h_refcount, -1);
if (ce) if (ce)
mb_cache_entry_release(ce); mb_cache_entry_release(ce);
vfs_dq_free_block(inode, 1); dquot_free_block(inode, 1);
mark_buffer_dirty(old_bh); mark_buffer_dirty(old_bh);
ea_bdebug(old_bh, "refcount now=%d", ea_bdebug(old_bh, "refcount now=%d",
le32_to_cpu(HDR(old_bh)->h_refcount)); le32_to_cpu(HDR(old_bh)->h_refcount));
@@ -797,7 +797,7 @@ ext2_xattr_delete_inode(struct inode *inode)
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
if (IS_SYNC(inode)) if (IS_SYNC(inode))
sync_dirty_buffer(bh); sync_dirty_buffer(bh);
vfs_dq_free_block(inode, 1); dquot_free_block(inode, 1);
} }
EXT2_I(inode)->i_file_acl = 0; EXT2_I(inode)->i_file_acl = 0;
+6 -5
View File
@@ -676,7 +676,7 @@ void ext3_free_blocks(handle_t *handle, struct inode *inode,
} }
ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks); ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks);
if (dquot_freed_blocks) if (dquot_freed_blocks)
vfs_dq_free_block(inode, dquot_freed_blocks); dquot_free_block(inode, dquot_freed_blocks);
return; return;
} }
@@ -1502,8 +1502,9 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
/* /*
* Check quota for allocation of this block. * Check quota for allocation of this block.
*/ */
if (vfs_dq_alloc_block(inode, num)) { err = dquot_alloc_block(inode, num);
*errp = -EDQUOT; if (err) {
*errp = err;
return 0; return 0;
} }
@@ -1713,7 +1714,7 @@ allocated:
*errp = 0; *errp = 0;
brelse(bitmap_bh); brelse(bitmap_bh);
vfs_dq_free_block(inode, *count-num); dquot_free_block(inode, *count-num);
*count = num; *count = num;
return ret_block; return ret_block;
@@ -1728,7 +1729,7 @@ out:
* Undo the block allocation * Undo the block allocation
*/ */
if (!performed_allocation) if (!performed_allocation)
vfs_dq_free_block(inode, *count); dquot_free_block(inode, *count);
brelse(bitmap_bh); brelse(bitmap_bh);
return 0; return 0;
} }
+1 -1
View File
@@ -3336,7 +3336,7 @@ int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode)
* i_size has been changed by generic_commit_write() and we thus need * i_size has been changed by generic_commit_write() and we thus need
* to include the updated inode in the current transaction. * to include the updated inode in the current transaction.
* *
* Also, vfs_dq_alloc_space() will always dirty the inode when blocks * Also, dquot_alloc_space() will always dirty the inode when blocks
* are allocated to the file. * are allocated to the file.
* *
* If the inode is marked synchronous, we don't honour that here - doing * If the inode is marked synchronous, we don't honour that here - doing
-2
View File
@@ -752,9 +752,7 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type,
static const struct dquot_operations ext3_quota_operations = { static const struct dquot_operations ext3_quota_operations = {
.initialize = dquot_initialize, .initialize = dquot_initialize,
.drop = dquot_drop, .drop = dquot_drop,
.alloc_space = dquot_alloc_space,
.alloc_inode = dquot_alloc_inode, .alloc_inode = dquot_alloc_inode,
.free_space = dquot_free_space,
.free_inode = dquot_free_inode, .free_inode = dquot_free_inode,
.transfer = dquot_transfer, .transfer = dquot_transfer,
.write_dquot = ext3_write_dquot, .write_dquot = ext3_write_dquot,
+4 -4
View File
@@ -500,7 +500,7 @@ ext3_xattr_release_block(handle_t *handle, struct inode *inode,
error = ext3_journal_dirty_metadata(handle, bh); error = ext3_journal_dirty_metadata(handle, bh);
if (IS_SYNC(inode)) if (IS_SYNC(inode))
handle->h_sync = 1; handle->h_sync = 1;
vfs_dq_free_block(inode, 1); dquot_free_block(inode, 1);
ea_bdebug(bh, "refcount now=%d; releasing", ea_bdebug(bh, "refcount now=%d; releasing",
le32_to_cpu(BHDR(bh)->h_refcount)); le32_to_cpu(BHDR(bh)->h_refcount));
if (ce) if (ce)
@@ -775,8 +775,8 @@ inserted:
else { else {
/* The old block is released after updating /* The old block is released after updating
the inode. */ the inode. */
error = -EDQUOT; error = dquot_alloc_block(inode, 1);
if (vfs_dq_alloc_block(inode, 1)) if (error)
goto cleanup; goto cleanup;
error = ext3_journal_get_write_access(handle, error = ext3_journal_get_write_access(handle,
new_bh); new_bh);
@@ -850,7 +850,7 @@ cleanup:
return error; return error;
cleanup_dquot: cleanup_dquot:
vfs_dq_free_block(inode, 1); dquot_free_block(inode, 1);
goto cleanup; goto cleanup;
bad_block: bad_block:
+11 -9
View File
@@ -1093,9 +1093,9 @@ void ext4_da_update_reserve_space(struct inode *inode,
/* Update quota subsystem */ /* Update quota subsystem */
if (quota_claim) { if (quota_claim) {
vfs_dq_claim_block(inode, used); dquot_claim_block(inode, used);
if (mdb_free) if (mdb_free)
vfs_dq_release_reservation_block(inode, mdb_free); dquot_release_reservation_block(inode, mdb_free);
} else { } else {
/* /*
* We did fallocate with an offset that is already delayed * We did fallocate with an offset that is already delayed
@@ -1106,8 +1106,8 @@ void ext4_da_update_reserve_space(struct inode *inode,
* that * that
*/ */
if (allocated_meta_blocks) if (allocated_meta_blocks)
vfs_dq_claim_block(inode, allocated_meta_blocks); dquot_claim_block(inode, allocated_meta_blocks);
vfs_dq_release_reservation_block(inode, mdb_free + used); dquot_release_reservation_block(inode, mdb_free + used);
} }
/* /*
@@ -1836,6 +1836,7 @@ static int ext4_da_reserve_space(struct inode *inode, sector_t lblock)
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
struct ext4_inode_info *ei = EXT4_I(inode); struct ext4_inode_info *ei = EXT4_I(inode);
unsigned long md_needed, md_reserved; unsigned long md_needed, md_reserved;
int ret;
/* /*
* recalculate the amount of metadata blocks to reserve * recalculate the amount of metadata blocks to reserve
@@ -1853,11 +1854,12 @@ repeat:
* later. Real quota accounting is done at pages writeout * later. Real quota accounting is done at pages writeout
* time. * time.
*/ */
if (vfs_dq_reserve_block(inode, md_needed + 1)) ret = dquot_reserve_block(inode, md_needed + 1);
return -EDQUOT; if (ret)
return ret;
if (ext4_claim_free_blocks(sbi, md_needed + 1)) { if (ext4_claim_free_blocks(sbi, md_needed + 1)) {
vfs_dq_release_reservation_block(inode, md_needed + 1); dquot_release_reservation_block(inode, md_needed + 1);
if (ext4_should_retry_alloc(inode->i_sb, &retries)) { if (ext4_should_retry_alloc(inode->i_sb, &retries)) {
yield(); yield();
goto repeat; goto repeat;
@@ -1914,7 +1916,7 @@ static void ext4_da_release_space(struct inode *inode, int to_free)
spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
vfs_dq_release_reservation_block(inode, to_free); dquot_release_reservation_block(inode, to_free);
} }
static void ext4_da_page_release_reservation(struct page *page, static void ext4_da_page_release_reservation(struct page *page,
@@ -5641,7 +5643,7 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
* i_size has been changed by generic_commit_write() and we thus need * i_size has been changed by generic_commit_write() and we thus need
* to include the updated inode in the current transaction. * to include the updated inode in the current transaction.
* *
* Also, vfs_dq_alloc_block() will always dirty the inode when blocks * Also, dquot_alloc_block() will always dirty the inode when blocks
* are allocated to the file. * are allocated to the file.
* *
* If the inode is marked synchronous, we don't honour that here - doing * If the inode is marked synchronous, we don't honour that here - doing
+3 -3
View File
@@ -4254,7 +4254,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
return 0; return 0;
} }
reserv_blks = ar->len; reserv_blks = ar->len;
while (ar->len && vfs_dq_alloc_block(ar->inode, ar->len)) { while (ar->len && dquot_alloc_block(ar->inode, ar->len)) {
ar->flags |= EXT4_MB_HINT_NOPREALLOC; ar->flags |= EXT4_MB_HINT_NOPREALLOC;
ar->len--; ar->len--;
} }
@@ -4331,7 +4331,7 @@ out2:
kmem_cache_free(ext4_ac_cachep, ac); kmem_cache_free(ext4_ac_cachep, ac);
out1: out1:
if (inquota && ar->len < inquota) if (inquota && ar->len < inquota)
vfs_dq_free_block(ar->inode, inquota - ar->len); dquot_free_block(ar->inode, inquota - ar->len);
out3: out3:
if (!ar->len) { if (!ar->len) {
if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag) if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag)
@@ -4646,7 +4646,7 @@ do_more:
sb->s_dirt = 1; sb->s_dirt = 1;
error_return: error_return:
if (freed) if (freed)
vfs_dq_free_block(inode, freed); dquot_free_block(inode, freed);
brelse(bitmap_bh); brelse(bitmap_bh);
ext4_std_error(sb, err); ext4_std_error(sb, err);
if (ac) if (ac)
-5
View File
@@ -1014,15 +1014,10 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
static const struct dquot_operations ext4_quota_operations = { static const struct dquot_operations ext4_quota_operations = {
.initialize = dquot_initialize, .initialize = dquot_initialize,
.drop = dquot_drop, .drop = dquot_drop,
.alloc_space = dquot_alloc_space,
.reserve_space = dquot_reserve_space,
.claim_space = dquot_claim_space,
.release_rsv = dquot_release_reserved_space,
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
.get_reserved_space = ext4_get_reserved_space, .get_reserved_space = ext4_get_reserved_space,
#endif #endif
.alloc_inode = dquot_alloc_inode, .alloc_inode = dquot_alloc_inode,
.free_space = dquot_free_space,
.free_inode = dquot_free_inode, .free_inode = dquot_free_inode,
.transfer = dquot_transfer, .transfer = dquot_transfer,
.write_dquot = ext4_write_dquot, .write_dquot = ext4_write_dquot,
+4 -4
View File
@@ -494,7 +494,7 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
error = ext4_handle_dirty_metadata(handle, inode, bh); error = ext4_handle_dirty_metadata(handle, inode, bh);
if (IS_SYNC(inode)) if (IS_SYNC(inode))
ext4_handle_sync(handle); ext4_handle_sync(handle);
vfs_dq_free_block(inode, 1); dquot_free_block(inode, 1);
ea_bdebug(bh, "refcount now=%d; releasing", ea_bdebug(bh, "refcount now=%d; releasing",
le32_to_cpu(BHDR(bh)->h_refcount)); le32_to_cpu(BHDR(bh)->h_refcount));
if (ce) if (ce)
@@ -787,8 +787,8 @@ inserted:
else { else {
/* The old block is released after updating /* The old block is released after updating
the inode. */ the inode. */
error = -EDQUOT; error = dquot_alloc_block(inode, 1);
if (vfs_dq_alloc_block(inode, 1)) if (error)
goto cleanup; goto cleanup;
error = ext4_journal_get_write_access(handle, error = ext4_journal_get_write_access(handle,
new_bh); new_bh);
@@ -876,7 +876,7 @@ cleanup:
return error; return error;
cleanup_dquot: cleanup_dquot:
vfs_dq_free_block(inode, 1); dquot_free_block(inode, 1);
goto cleanup; goto cleanup;
bad_block: bad_block:
+15 -13
View File
@@ -381,10 +381,10 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
* It's time to move the inline table to an external * It's time to move the inline table to an external
* page and begin to build the xtree * page and begin to build the xtree
*/ */
if (vfs_dq_alloc_block(ip, sbi->nbperpage)) if (dquot_alloc_block(ip, sbi->nbperpage))
goto clean_up; goto clean_up;
if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) { if (dbAlloc(ip, 0, sbi->nbperpage, &xaddr)) {
vfs_dq_free_block(ip, sbi->nbperpage); dquot_free_block(ip, sbi->nbperpage);
goto clean_up; goto clean_up;
} }
@@ -408,7 +408,7 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
memcpy(&jfs_ip->i_dirtable, temp_table, memcpy(&jfs_ip->i_dirtable, temp_table,
sizeof (temp_table)); sizeof (temp_table));
dbFree(ip, xaddr, sbi->nbperpage); dbFree(ip, xaddr, sbi->nbperpage);
vfs_dq_free_block(ip, sbi->nbperpage); dquot_free_block(ip, sbi->nbperpage);
goto clean_up; goto clean_up;
} }
ip->i_size = PSIZE; ip->i_size = PSIZE;
@@ -1027,10 +1027,9 @@ static int dtSplitUp(tid_t tid,
n = xlen; n = xlen;
/* Allocate blocks to quota. */ /* Allocate blocks to quota. */
if (vfs_dq_alloc_block(ip, n)) { rc = dquot_alloc_block(ip, n);
rc = -EDQUOT; if (rc)
goto extendOut; goto extendOut;
}
quota_allocation += n; quota_allocation += n;
if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen, if ((rc = dbReAlloc(sbi->ipbmap, xaddr, (s64) xlen,
@@ -1308,7 +1307,7 @@ static int dtSplitUp(tid_t tid,
/* Rollback quota allocation */ /* Rollback quota allocation */
if (rc && quota_allocation) if (rc && quota_allocation)
vfs_dq_free_block(ip, quota_allocation); dquot_free_block(ip, quota_allocation);
dtSplitUp_Exit: dtSplitUp_Exit:
@@ -1369,9 +1368,10 @@ static int dtSplitPage(tid_t tid, struct inode *ip, struct dtsplit * split,
return -EIO; return -EIO;
/* Allocate blocks to quota. */ /* Allocate blocks to quota. */
if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) { rc = dquot_alloc_block(ip, lengthPXD(pxd));
if (rc) {
release_metapage(rmp); release_metapage(rmp);
return -EDQUOT; return rc;
} }
jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp); jfs_info("dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
@@ -1892,6 +1892,7 @@ static int dtSplitRoot(tid_t tid,
struct dt_lock *dtlck; struct dt_lock *dtlck;
struct tlock *tlck; struct tlock *tlck;
struct lv *lv; struct lv *lv;
int rc;
/* get split root page */ /* get split root page */
smp = split->mp; smp = split->mp;
@@ -1916,9 +1917,10 @@ static int dtSplitRoot(tid_t tid,
rp = rmp->data; rp = rmp->data;
/* Allocate blocks to quota. */ /* Allocate blocks to quota. */
if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) { rc = dquot_alloc_block(ip, lengthPXD(pxd));
if (rc) {
release_metapage(rmp); release_metapage(rmp);
return -EDQUOT; return rc;
} }
BT_MARK_DIRTY(rmp, ip); BT_MARK_DIRTY(rmp, ip);
@@ -2287,7 +2289,7 @@ static int dtDeleteUp(tid_t tid, struct inode *ip,
xlen = lengthPXD(&fp->header.self); xlen = lengthPXD(&fp->header.self);
/* Free quota allocation. */ /* Free quota allocation. */
vfs_dq_free_block(ip, xlen); dquot_free_block(ip, xlen);
/* free/invalidate its buffer page */ /* free/invalidate its buffer page */
discard_metapage(fmp); discard_metapage(fmp);
@@ -2363,7 +2365,7 @@ static int dtDeleteUp(tid_t tid, struct inode *ip,
xlen = lengthPXD(&p->header.self); xlen = lengthPXD(&p->header.self);
/* Free quota allocation */ /* Free quota allocation */
vfs_dq_free_block(ip, xlen); dquot_free_block(ip, xlen);
/* free/invalidate its buffer page */ /* free/invalidate its buffer page */
discard_metapage(mp); discard_metapage(mp);
+9 -7
View File
@@ -141,10 +141,11 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, bool abnr)
} }
/* Allocate blocks to quota. */ /* Allocate blocks to quota. */
if (vfs_dq_alloc_block(ip, nxlen)) { rc = dquot_alloc_block(ip, nxlen);
if (rc) {
dbFree(ip, nxaddr, (s64) nxlen); dbFree(ip, nxaddr, (s64) nxlen);
mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(ip)->commit_mutex);
return -EDQUOT; return rc;
} }
/* determine the value of the extent flag */ /* determine the value of the extent flag */
@@ -164,7 +165,7 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp, bool abnr)
*/ */
if (rc) { if (rc) {
dbFree(ip, nxaddr, nxlen); dbFree(ip, nxaddr, nxlen);
vfs_dq_free_block(ip, nxlen); dquot_free_block(ip, nxlen);
mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(ip)->commit_mutex);
return (rc); return (rc);
} }
@@ -256,10 +257,11 @@ int extRealloc(struct inode *ip, s64 nxlen, xad_t * xp, bool abnr)
goto exit; goto exit;
/* Allocat blocks to quota. */ /* Allocat blocks to quota. */
if (vfs_dq_alloc_block(ip, nxlen)) { rc = dquot_alloc_block(ip, nxlen);
if (rc) {
dbFree(ip, nxaddr, (s64) nxlen); dbFree(ip, nxaddr, (s64) nxlen);
mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(ip)->commit_mutex);
return -EDQUOT; return rc;
} }
delta = nxlen - xlen; delta = nxlen - xlen;
@@ -297,7 +299,7 @@ int extRealloc(struct inode *ip, s64 nxlen, xad_t * xp, bool abnr)
/* extend the extent */ /* extend the extent */
if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) { if ((rc = xtExtend(0, ip, xoff + xlen, (int) nextend, 0))) {
dbFree(ip, xaddr + xlen, delta); dbFree(ip, xaddr + xlen, delta);
vfs_dq_free_block(ip, nxlen); dquot_free_block(ip, nxlen);
goto exit; goto exit;
} }
} else { } else {
@@ -308,7 +310,7 @@ int extRealloc(struct inode *ip, s64 nxlen, xad_t * xp, bool abnr)
*/ */
if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) { if ((rc = xtTailgate(0, ip, xoff, (int) ntail, nxaddr, 0))) {
dbFree(ip, nxaddr, nxlen); dbFree(ip, nxaddr, nxlen);
vfs_dq_free_block(ip, nxlen); dquot_free_block(ip, nxlen);
goto exit; goto exit;
} }
} }
+11 -10
View File
@@ -585,10 +585,10 @@ int xtInsert(tid_t tid, /* transaction id */
hint = addressXAD(xad) + lengthXAD(xad) - 1; hint = addressXAD(xad) + lengthXAD(xad) - 1;
} else } else
hint = 0; hint = 0;
if ((rc = vfs_dq_alloc_block(ip, xlen))) if ((rc = dquot_alloc_block(ip, xlen)))
goto out; goto out;
if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) { if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
vfs_dq_free_block(ip, xlen); dquot_free_block(ip, xlen);
goto out; goto out;
} }
} }
@@ -617,7 +617,7 @@ int xtInsert(tid_t tid, /* transaction id */
/* undo data extent allocation */ /* undo data extent allocation */
if (*xaddrp == 0) { if (*xaddrp == 0) {
dbFree(ip, xaddr, (s64) xlen); dbFree(ip, xaddr, (s64) xlen);
vfs_dq_free_block(ip, xlen); dquot_free_block(ip, xlen);
} }
return rc; return rc;
} }
@@ -985,10 +985,9 @@ xtSplitPage(tid_t tid, struct inode *ip,
rbn = addressPXD(pxd); rbn = addressPXD(pxd);
/* Allocate blocks to quota. */ /* Allocate blocks to quota. */
if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) { rc = dquot_alloc_block(ip, lengthPXD(pxd));
rc = -EDQUOT; if (rc)
goto clean_up; goto clean_up;
}
quota_allocation += lengthPXD(pxd); quota_allocation += lengthPXD(pxd);
@@ -1195,7 +1194,7 @@ xtSplitPage(tid_t tid, struct inode *ip,
/* Rollback quota allocation. */ /* Rollback quota allocation. */
if (quota_allocation) if (quota_allocation)
vfs_dq_free_block(ip, quota_allocation); dquot_free_block(ip, quota_allocation);
return (rc); return (rc);
} }
@@ -1235,6 +1234,7 @@ xtSplitRoot(tid_t tid,
struct pxdlist *pxdlist; struct pxdlist *pxdlist;
struct tlock *tlck; struct tlock *tlck;
struct xtlock *xtlck; struct xtlock *xtlck;
int rc;
sp = &JFS_IP(ip)->i_xtroot; sp = &JFS_IP(ip)->i_xtroot;
@@ -1252,9 +1252,10 @@ xtSplitRoot(tid_t tid,
return -EIO; return -EIO;
/* Allocate blocks to quota. */ /* Allocate blocks to quota. */
if (vfs_dq_alloc_block(ip, lengthPXD(pxd))) { rc = dquot_alloc_block(ip, lengthPXD(pxd));
if (rc) {
release_metapage(rmp); release_metapage(rmp);
return -EDQUOT; return rc;
} }
jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp); jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
@@ -3680,7 +3681,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
ip->i_size = newsize; ip->i_size = newsize;
/* update quota allocation to reflect freed blocks */ /* update quota allocation to reflect freed blocks */
vfs_dq_free_block(ip, nfreed); dquot_free_block(ip, nfreed);
/* /*
* free tlock of invalidated pages * free tlock of invalidated pages
+9 -8
View File
@@ -260,14 +260,14 @@ static int ea_write(struct inode *ip, struct jfs_ea_list *ealist, int size,
nblocks = (size + (sb->s_blocksize - 1)) >> sb->s_blocksize_bits; nblocks = (size + (sb->s_blocksize - 1)) >> sb->s_blocksize_bits;
/* Allocate new blocks to quota. */ /* Allocate new blocks to quota. */
if (vfs_dq_alloc_block(ip, nblocks)) { rc = dquot_alloc_block(ip, nblocks);
return -EDQUOT; if (rc)
} return rc;
rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno); rc = dbAlloc(ip, INOHINT(ip), nblocks, &blkno);
if (rc) { if (rc) {
/*Rollback quota allocation. */ /*Rollback quota allocation. */
vfs_dq_free_block(ip, nblocks); dquot_free_block(ip, nblocks);
return rc; return rc;
} }
@@ -332,7 +332,7 @@ static int ea_write(struct inode *ip, struct jfs_ea_list *ealist, int size,
failed: failed:
/* Rollback quota allocation. */ /* Rollback quota allocation. */
vfs_dq_free_block(ip, nblocks); dquot_free_block(ip, nblocks);
dbFree(ip, blkno, nblocks); dbFree(ip, blkno, nblocks);
return rc; return rc;
@@ -538,7 +538,8 @@ static int ea_get(struct inode *inode, struct ea_buffer *ea_buf, int min_size)
if (blocks_needed > current_blocks) { if (blocks_needed > current_blocks) {
/* Allocate new blocks to quota. */ /* Allocate new blocks to quota. */
if (vfs_dq_alloc_block(inode, blocks_needed)) rc = dquot_alloc_block(inode, blocks_needed);
if (rc)
return -EDQUOT; return -EDQUOT;
quota_allocation = blocks_needed; quota_allocation = blocks_needed;
@@ -602,7 +603,7 @@ static int ea_get(struct inode *inode, struct ea_buffer *ea_buf, int min_size)
clean_up: clean_up:
/* Rollback quota allocation */ /* Rollback quota allocation */
if (quota_allocation) if (quota_allocation)
vfs_dq_free_block(inode, quota_allocation); dquot_free_block(inode, quota_allocation);
return (rc); return (rc);
} }
@@ -677,7 +678,7 @@ static int ea_put(tid_t tid, struct inode *inode, struct ea_buffer *ea_buf,
/* If old blocks exist, they must be removed from quota allocation. */ /* If old blocks exist, they must be removed from quota allocation. */
if (old_blocks) if (old_blocks)
vfs_dq_free_block(inode, old_blocks); dquot_free_block(inode, old_blocks);
inode->i_ctime = CURRENT_TIME; inode->i_ctime = CURRENT_TIME;
+6 -7
View File
@@ -5712,7 +5712,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
goto out; goto out;
} }
vfs_dq_free_space_nodirty(inode, dquot_free_space_nodirty(inode,
ocfs2_clusters_to_bytes(inode->i_sb, len)); ocfs2_clusters_to_bytes(inode->i_sb, len));
ret = ocfs2_remove_extent(handle, et, cpos, len, meta_ac, dealloc); ret = ocfs2_remove_extent(handle, et, cpos, len, meta_ac, dealloc);
@@ -6935,7 +6935,7 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
goto bail; goto bail;
} }
vfs_dq_free_space_nodirty(inode, dquot_free_space_nodirty(inode,
ocfs2_clusters_to_bytes(osb->sb, clusters_to_del)); ocfs2_clusters_to_bytes(osb->sb, clusters_to_del));
spin_lock(&OCFS2_I(inode)->ip_lock); spin_lock(&OCFS2_I(inode)->ip_lock);
OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters) - OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters) -
@@ -7300,11 +7300,10 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
unsigned int page_end; unsigned int page_end;
u64 phys; u64 phys;
if (vfs_dq_alloc_space_nodirty(inode, ret = dquot_alloc_space_nodirty(inode,
ocfs2_clusters_to_bytes(osb->sb, 1))) { ocfs2_clusters_to_bytes(osb->sb, 1));
ret = -EDQUOT; if (ret)
goto out_commit; goto out_commit;
}
did_quota = 1; did_quota = 1;
ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off,
@@ -7380,7 +7379,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
out_commit: out_commit:
if (ret < 0 && did_quota) if (ret < 0 && did_quota)
vfs_dq_free_space_nodirty(inode, dquot_free_space_nodirty(inode,
ocfs2_clusters_to_bytes(osb->sb, 1)); ocfs2_clusters_to_bytes(osb->sb, 1));
ocfs2_commit_trans(osb, handle); ocfs2_commit_trans(osb, handle);
+6 -5
View File
@@ -1763,10 +1763,11 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
wc->w_handle = handle; wc->w_handle = handle;
if (clusters_to_alloc && vfs_dq_alloc_space_nodirty(inode, if (clusters_to_alloc) {
ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc))) { ret = dquot_alloc_space_nodirty(inode,
ret = -EDQUOT; ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc));
goto out_commit; if (ret)
goto out_commit;
} }
/* /*
* We don't want this to fail in ocfs2_write_end(), so do it * We don't want this to fail in ocfs2_write_end(), so do it
@@ -1809,7 +1810,7 @@ success:
return 0; return 0;
out_quota: out_quota:
if (clusters_to_alloc) if (clusters_to_alloc)
vfs_dq_free_space(inode, dquot_free_space(inode,
ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc)); ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc));
out_commit: out_commit:
ocfs2_commit_trans(osb, handle); ocfs2_commit_trans(osb, handle);
+16 -21
View File
@@ -2964,12 +2964,10 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
goto out; goto out;
} }
if (vfs_dq_alloc_space_nodirty(dir, ret = dquot_alloc_space_nodirty(dir,
ocfs2_clusters_to_bytes(osb->sb, ocfs2_clusters_to_bytes(osb->sb, alloc + dx_alloc));
alloc + dx_alloc))) { if (ret)
ret = -EDQUOT;
goto out_commit; goto out_commit;
}
did_quota = 1; did_quota = 1;
if (ocfs2_supports_indexed_dirs(osb) && !dx_inline) { if (ocfs2_supports_indexed_dirs(osb) && !dx_inline) {
@@ -3178,7 +3176,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
out_commit: out_commit:
if (ret < 0 && did_quota) if (ret < 0 && did_quota)
vfs_dq_free_space_nodirty(dir, bytes_allocated); dquot_free_space_nodirty(dir, bytes_allocated);
ocfs2_commit_trans(osb, handle); ocfs2_commit_trans(osb, handle);
@@ -3221,11 +3219,10 @@ static int ocfs2_do_extend_dir(struct super_block *sb,
if (extend) { if (extend) {
u32 offset = OCFS2_I(dir)->ip_clusters; u32 offset = OCFS2_I(dir)->ip_clusters;
if (vfs_dq_alloc_space_nodirty(dir, status = dquot_alloc_space_nodirty(dir,
ocfs2_clusters_to_bytes(sb, 1))) { ocfs2_clusters_to_bytes(sb, 1));
status = -EDQUOT; if (status)
goto bail; goto bail;
}
did_quota = 1; did_quota = 1;
status = ocfs2_add_inode_data(OCFS2_SB(sb), dir, &offset, status = ocfs2_add_inode_data(OCFS2_SB(sb), dir, &offset,
@@ -3254,7 +3251,7 @@ static int ocfs2_do_extend_dir(struct super_block *sb,
status = 0; status = 0;
bail: bail:
if (did_quota && status < 0) if (did_quota && status < 0)
vfs_dq_free_space_nodirty(dir, ocfs2_clusters_to_bytes(sb, 1)); dquot_free_space_nodirty(dir, ocfs2_clusters_to_bytes(sb, 1));
mlog_exit(status); mlog_exit(status);
return status; return status;
} }
@@ -3889,11 +3886,10 @@ static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir,
goto out; goto out;
} }
if (vfs_dq_alloc_space_nodirty(dir, ret = dquot_alloc_space_nodirty(dir,
ocfs2_clusters_to_bytes(dir->i_sb, 1))) { ocfs2_clusters_to_bytes(dir->i_sb, 1));
ret = -EDQUOT; if (ret)
goto out_commit; goto out_commit;
}
did_quota = 1; did_quota = 1;
ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir), dx_leaf_bh, ret = ocfs2_journal_access_dl(handle, INODE_CACHE(dir), dx_leaf_bh,
@@ -3983,7 +3979,7 @@ static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir,
out_commit: out_commit:
if (ret < 0 && did_quota) if (ret < 0 && did_quota)
vfs_dq_free_space_nodirty(dir, dquot_free_space_nodirty(dir,
ocfs2_clusters_to_bytes(dir->i_sb, 1)); ocfs2_clusters_to_bytes(dir->i_sb, 1));
ocfs2_commit_trans(osb, handle); ocfs2_commit_trans(osb, handle);
@@ -4165,11 +4161,10 @@ static int ocfs2_expand_inline_dx_root(struct inode *dir,
goto out; goto out;
} }
if (vfs_dq_alloc_space_nodirty(dir, ret = dquot_alloc_space_nodirty(dir,
ocfs2_clusters_to_bytes(osb->sb, 1))) { ocfs2_clusters_to_bytes(osb->sb, 1));
ret = -EDQUOT; if (ret)
goto out_commit; goto out_commit;
}
did_quota = 1; did_quota = 1;
/* /*
@@ -4229,7 +4224,7 @@ static int ocfs2_expand_inline_dx_root(struct inode *dir,
out_commit: out_commit:
if (ret < 0 && did_quota) if (ret < 0 && did_quota)
vfs_dq_free_space_nodirty(dir, dquot_free_space_nodirty(dir,
ocfs2_clusters_to_bytes(dir->i_sb, 1)); ocfs2_clusters_to_bytes(dir->i_sb, 1));
ocfs2_commit_trans(osb, handle); ocfs2_commit_trans(osb, handle);
+5 -6
View File
@@ -629,11 +629,10 @@ restart_all:
} }
restarted_transaction: restarted_transaction:
if (vfs_dq_alloc_space_nodirty(inode, ocfs2_clusters_to_bytes(osb->sb, status = dquot_alloc_space_nodirty(inode,
clusters_to_add))) { ocfs2_clusters_to_bytes(osb->sb, clusters_to_add));
status = -EDQUOT; if (status)
goto leave; goto leave;
}
did_quota = 1; did_quota = 1;
/* reserve a write to the file entry early on - that we if we /* reserve a write to the file entry early on - that we if we
@@ -674,7 +673,7 @@ restarted_transaction:
clusters_to_add -= (OCFS2_I(inode)->ip_clusters - prev_clusters); clusters_to_add -= (OCFS2_I(inode)->ip_clusters - prev_clusters);
spin_unlock(&OCFS2_I(inode)->ip_lock); spin_unlock(&OCFS2_I(inode)->ip_lock);
/* Release unused quota reservation */ /* Release unused quota reservation */
vfs_dq_free_space(inode, dquot_free_space(inode,
ocfs2_clusters_to_bytes(osb->sb, clusters_to_add)); ocfs2_clusters_to_bytes(osb->sb, clusters_to_add));
did_quota = 0; did_quota = 0;
@@ -710,7 +709,7 @@ restarted_transaction:
leave: leave:
if (status < 0 && did_quota) if (status < 0 && did_quota)
vfs_dq_free_space(inode, dquot_free_space(inode,
ocfs2_clusters_to_bytes(osb->sb, clusters_to_add)); ocfs2_clusters_to_bytes(osb->sb, clusters_to_add));
if (handle) { if (handle) {
ocfs2_commit_trans(osb, handle); ocfs2_commit_trans(osb, handle);
+4 -5
View File
@@ -1716,11 +1716,10 @@ static int ocfs2_symlink(struct inode *dir,
u32 offset = 0; u32 offset = 0;
inode->i_op = &ocfs2_symlink_inode_operations; inode->i_op = &ocfs2_symlink_inode_operations;
if (vfs_dq_alloc_space_nodirty(inode, status = dquot_alloc_space_nodirty(inode,
ocfs2_clusters_to_bytes(osb->sb, 1))) { ocfs2_clusters_to_bytes(osb->sb, 1));
status = -EDQUOT; if (status)
goto bail; goto bail;
}
did_quota = 1; did_quota = 1;
status = ocfs2_add_inode_data(osb, inode, &offset, 1, 0, status = ocfs2_add_inode_data(osb, inode, &offset, 1, 0,
new_fe_bh, new_fe_bh,
@@ -1788,7 +1787,7 @@ static int ocfs2_symlink(struct inode *dir,
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
bail: bail:
if (status < 0 && did_quota) if (status < 0 && did_quota)
vfs_dq_free_space_nodirty(inode, dquot_free_space_nodirty(inode,
ocfs2_clusters_to_bytes(osb->sb, 1)); ocfs2_clusters_to_bytes(osb->sb, 1));
if (status < 0 && did_quota_inode) if (status < 0 && did_quota_inode)
vfs_dq_free_inode(inode); vfs_dq_free_inode(inode);

Some files were not shown because too many files have changed in this diff Show More