diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2013-09-27 07:49:33 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2013-09-27 07:49:33 -0400 |
commit | af5c269799feaef110e59ce55b497cdd08712b0c (patch) | |
tree | c5aad271b31ba67c5eef857b927ed2dc45186176 /fs/gfs2 | |
parent | 5ca1db41ecdeb0358b968265fadb755213558a85 (diff) |
GFS2: Clean up reservation removal
The reservation for an inode should be cleared when it is truncated so
that we can start again at a different offset for future allocations.
We could try and do better than that, by resetting the search based on
where the truncation started from, but this is only a first step.
In addition, there are three callers of gfs2_rs_delete() but only one
of those should really be testing the value of i_writecount. While
we get away with that in the other cases currently, I think it would
be better if we made that test specific to the one case which
requires it.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/bmap.c | 4 | ||||
-rw-r--r-- | fs/gfs2/file.c | 2 | ||||
-rw-r--r-- | fs/gfs2/inode.c | 2 | ||||
-rw-r--r-- | fs/gfs2/rgrp.c | 7 | ||||
-rw-r--r-- | fs/gfs2/rgrp.h | 2 | ||||
-rw-r--r-- | fs/gfs2/super.c | 2 |
6 files changed, 10 insertions, 9 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 62a65fc448dc..21ad0f11cad4 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c | |||
@@ -1279,6 +1279,7 @@ do_grow_qunlock: | |||
1279 | 1279 | ||
1280 | int gfs2_setattr_size(struct inode *inode, u64 newsize) | 1280 | int gfs2_setattr_size(struct inode *inode, u64 newsize) |
1281 | { | 1281 | { |
1282 | struct gfs2_inode *ip = GFS2_I(inode); | ||
1282 | int ret; | 1283 | int ret; |
1283 | u64 oldsize; | 1284 | u64 oldsize; |
1284 | 1285 | ||
@@ -1294,7 +1295,7 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize) | |||
1294 | 1295 | ||
1295 | inode_dio_wait(inode); | 1296 | inode_dio_wait(inode); |
1296 | 1297 | ||
1297 | ret = gfs2_rs_alloc(GFS2_I(inode)); | 1298 | ret = gfs2_rs_alloc(ip); |
1298 | if (ret) | 1299 | if (ret) |
1299 | goto out; | 1300 | goto out; |
1300 | 1301 | ||
@@ -1304,6 +1305,7 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize) | |||
1304 | goto out; | 1305 | goto out; |
1305 | } | 1306 | } |
1306 | 1307 | ||
1308 | gfs2_rs_deltree(ip->i_res); | ||
1307 | ret = do_shrink(inode, oldsize, newsize); | 1309 | ret = do_shrink(inode, oldsize, newsize); |
1308 | out: | 1310 | out: |
1309 | put_write_access(inode); | 1311 | put_write_access(inode); |
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 0621b46d474d..9ad20edc9c27 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c | |||
@@ -620,7 +620,7 @@ static int gfs2_release(struct inode *inode, struct file *file) | |||
620 | if (!(file->f_mode & FMODE_WRITE)) | 620 | if (!(file->f_mode & FMODE_WRITE)) |
621 | return 0; | 621 | return 0; |
622 | 622 | ||
623 | gfs2_rs_delete(ip); | 623 | gfs2_rs_delete(ip, &inode->i_writecount); |
624 | return 0; | 624 | return 0; |
625 | } | 625 | } |
626 | 626 | ||
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index cd58611912f5..4b79c19100d2 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -711,7 +711,7 @@ fail_gunlock2: | |||
711 | fail_free_inode: | 711 | fail_free_inode: |
712 | if (ip->i_gl) | 712 | if (ip->i_gl) |
713 | gfs2_glock_put(ip->i_gl); | 713 | gfs2_glock_put(ip->i_gl); |
714 | gfs2_rs_delete(ip); | 714 | gfs2_rs_delete(ip, NULL); |
715 | free_inode_nonrcu(inode); | 715 | free_inode_nonrcu(inode); |
716 | inode = NULL; | 716 | inode = NULL; |
717 | fail_gunlock: | 717 | fail_gunlock: |
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 285dd363199a..d4d10fadab79 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -661,14 +661,13 @@ void gfs2_rs_deltree(struct gfs2_blkreserv *rs) | |||
661 | /** | 661 | /** |
662 | * gfs2_rs_delete - delete a multi-block reservation | 662 | * gfs2_rs_delete - delete a multi-block reservation |
663 | * @ip: The inode for this reservation | 663 | * @ip: The inode for this reservation |
664 | * @wcount: The inode's write count, or NULL | ||
664 | * | 665 | * |
665 | */ | 666 | */ |
666 | void gfs2_rs_delete(struct gfs2_inode *ip) | 667 | void gfs2_rs_delete(struct gfs2_inode *ip, atomic_t *wcount) |
667 | { | 668 | { |
668 | struct inode *inode = &ip->i_inode; | ||
669 | |||
670 | down_write(&ip->i_rw_mutex); | 669 | down_write(&ip->i_rw_mutex); |
671 | if (ip->i_res && atomic_read(&inode->i_writecount) <= 1) { | 670 | if (ip->i_res && ((wcount == NULL) || (atomic_read(wcount) <= 1))) { |
672 | gfs2_rs_deltree(ip->i_res); | 671 | gfs2_rs_deltree(ip->i_res); |
673 | BUG_ON(ip->i_res->rs_free); | 672 | BUG_ON(ip->i_res->rs_free); |
674 | kmem_cache_free(gfs2_rsrv_cachep, ip->i_res); | 673 | kmem_cache_free(gfs2_rsrv_cachep, ip->i_res); |
diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h index 5b3f4a896e6c..57ea16ba3414 100644 --- a/fs/gfs2/rgrp.h +++ b/fs/gfs2/rgrp.h | |||
@@ -48,7 +48,7 @@ extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n, | |||
48 | 48 | ||
49 | extern int gfs2_rs_alloc(struct gfs2_inode *ip); | 49 | extern int gfs2_rs_alloc(struct gfs2_inode *ip); |
50 | extern void gfs2_rs_deltree(struct gfs2_blkreserv *rs); | 50 | extern void gfs2_rs_deltree(struct gfs2_blkreserv *rs); |
51 | extern void gfs2_rs_delete(struct gfs2_inode *ip); | 51 | extern void gfs2_rs_delete(struct gfs2_inode *ip, atomic_t *wcount); |
52 | extern void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta); | 52 | extern void __gfs2_free_blocks(struct gfs2_inode *ip, u64 bstart, u32 blen, int meta); |
53 | extern void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen); | 53 | extern void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen); |
54 | extern void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip); | 54 | extern void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip); |
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index e5639dec66c4..35da5b19c0de 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
@@ -1526,7 +1526,7 @@ out_unlock: | |||
1526 | out: | 1526 | out: |
1527 | /* Case 3 starts here */ | 1527 | /* Case 3 starts here */ |
1528 | truncate_inode_pages(&inode->i_data, 0); | 1528 | truncate_inode_pages(&inode->i_data, 0); |
1529 | gfs2_rs_delete(ip); | 1529 | gfs2_rs_delete(ip, NULL); |
1530 | gfs2_ordered_del_inode(ip); | 1530 | gfs2_ordered_del_inode(ip); |
1531 | clear_inode(inode); | 1531 | clear_inode(inode); |
1532 | gfs2_dir_hash_inval(ip); | 1532 | gfs2_dir_hash_inval(ip); |