Skip to content

Commit 7336905

Browse files
author
Andreas Gruenbacher
committed
gfs2: gfs2_setattr_size error path fix
When gfs2_setattr_size() fails, it calls gfs2_rs_delete(ip, NULL) to get rid of any reservations the inode may have. Instead, it should pass in the inode's write count as the second parameter to allow gfs2_rs_delete() to figure out if the inode has any writers left. In a next step, there are two instances of gfs2_rs_delete(ip, NULL) left where we know that there can be no other users of the inode. Replace those with gfs2_rs_deltree(&ip->i_res) to avoid the unnecessary write count check. With that, gfs2_rs_delete() is only called with the inode's actual write count, so get rid of the second parameter. Fixes: a097dc7 ("GFS2: Make rgrp reservations part of the gfs2_inode structure") Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 428f651 commit 7336905

6 files changed

Lines changed: 9 additions & 8 deletions

File tree

fs/gfs2/bmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,7 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)
21462146

21472147
ret = do_shrink(inode, newsize);
21482148
out:
2149-
gfs2_rs_delete(ip, NULL);
2149+
gfs2_rs_delete(ip);
21502150
gfs2_qa_put(ip);
21512151
return ret;
21522152
}

fs/gfs2/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ static int gfs2_release(struct inode *inode, struct file *file)
706706

707707
if (file->f_mode & FMODE_WRITE) {
708708
if (gfs2_rs_active(&ip->i_res))
709-
gfs2_rs_delete(ip, &inode->i_writecount);
709+
gfs2_rs_delete(ip);
710710
gfs2_qa_put(ip);
711711
}
712712
return 0;

fs/gfs2/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
793793
if (free_vfs_inode) /* else evict will do the put for us */
794794
gfs2_glock_put(ip->i_gl);
795795
}
796-
gfs2_rs_delete(ip, NULL);
796+
gfs2_rs_deltree(&ip->i_res);
797797
gfs2_qa_put(ip);
798798
fail_free_acls:
799799
posix_acl_release(default_acl);

fs/gfs2/rgrp.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,13 +680,14 @@ void gfs2_rs_deltree(struct gfs2_blkreserv *rs)
680680
/**
681681
* gfs2_rs_delete - delete a multi-block reservation
682682
* @ip: The inode for this reservation
683-
* @wcount: The inode's write count, or NULL
684683
*
685684
*/
686-
void gfs2_rs_delete(struct gfs2_inode *ip, atomic_t *wcount)
685+
void gfs2_rs_delete(struct gfs2_inode *ip)
687686
{
687+
struct inode *inode = &ip->i_inode;
688+
688689
down_write(&ip->i_rw_mutex);
689-
if ((wcount == NULL) || (atomic_read(wcount) <= 1))
690+
if (atomic_read(&inode->i_writecount) <= 1)
690691
gfs2_rs_deltree(&ip->i_res);
691692
up_write(&ip->i_rw_mutex);
692693
}

fs/gfs2/rgrp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n,
4545
bool dinode, u64 *generation);
4646

4747
extern void gfs2_rs_deltree(struct gfs2_blkreserv *rs);
48-
extern void gfs2_rs_delete(struct gfs2_inode *ip, atomic_t *wcount);
48+
extern void gfs2_rs_delete(struct gfs2_inode *ip);
4949
extern void __gfs2_free_blocks(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
5050
u64 bstart, u32 blen, int meta);
5151
extern void gfs2_free_meta(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,

fs/gfs2/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,7 @@ static void gfs2_evict_inode(struct inode *inode)
13961396
truncate_inode_pages_final(&inode->i_data);
13971397
if (ip->i_qadata)
13981398
gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0);
1399-
gfs2_rs_delete(ip, NULL);
1399+
gfs2_rs_deltree(&ip->i_res);
14001400
gfs2_ordered_del_inode(ip);
14011401
clear_inode(inode);
14021402
gfs2_dir_hash_inval(ip);

0 commit comments

Comments
 (0)