diff options
author | Bob Peterson <rpeterso@redhat.com> | 2020-09-11 09:29:25 -0500 |
---|---|---|
committer | Andreas Gruenbacher <agruenba@redhat.com> | 2020-10-14 23:54:41 +0200 |
commit | 6e7e9a505571db3edc926f4bc972c7ed3da29a9d (patch) | |
tree | 21922f3adca551a312139cac129d269b4616ac33 /fs/gfs2/super.c | |
parent | 23d828fc3f1e309bbc23bab817e6b5c40b06d9b9 (diff) | |
download | lwn-6e7e9a505571db3edc926f4bc972c7ed3da29a9d.tar.gz lwn-6e7e9a505571db3edc926f4bc972c7ed3da29a9d.zip |
gfs2: factor evict_unlinked_inode out of gfs2_evict_inode
Function gfs2_evict_inode is way too big, complex and unreadable. This
is a baby step toward breaking it apart to be more readable. It factors
out the portion that deletes the online bits for a dinode that is
unlinked and needs to be deleted. A future patch will factor out more.
(If I factor out too much, the patch itself becomes unreadable).
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Diffstat (limited to 'fs/gfs2/super.c')
-rw-r--r-- | fs/gfs2/super.c | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index ab08b9a1102c..b5279a1d9cb0 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -1311,6 +1311,45 @@ static bool gfs2_upgrade_iopen_glock(struct inode *inode) } /** + * evict_unlinked_inode - delete the pieces of an unlinked evicted inode + * @inode: The inode to evict + */ +static int evict_unlinked_inode(struct inode *inode) +{ + struct gfs2_inode *ip = GFS2_I(inode); + int ret; + + if (S_ISDIR(inode->i_mode) && + (ip->i_diskflags & GFS2_DIF_EXHASH)) { + ret = gfs2_dir_exhash_dealloc(ip); + if (ret) + goto out; + } + + if (ip->i_eattr) { + ret = gfs2_ea_dealloc(ip); + if (ret) + goto out; + } + + if (!gfs2_is_stuffed(ip)) { + ret = gfs2_file_dealloc(ip); + if (ret) + goto out; + } + + /* We're about to clear the bitmap for the dinode, but as soon as we + do, gfs2_create_inode can create another inode at the same block + location and try to set gl_object again. We clear gl_object here so + that subsequent inode creates don't see an old gl_object. */ + glock_clear_object(ip->i_gl, ip); + ret = gfs2_dinode_dealloc(ip); + gfs2_inode_remember_delete(ip->i_gl, ip->i_no_formal_ino); +out: + return ret; +} + +/** * gfs2_evict_inode - Remove an inode from cache * @inode: The inode to evict * @@ -1396,33 +1435,7 @@ out_delete: goto out_truncate; } } - - if (S_ISDIR(inode->i_mode) && - (ip->i_diskflags & GFS2_DIF_EXHASH)) { - ret = gfs2_dir_exhash_dealloc(ip); - if (ret) - goto out_unlock; - } - - if (ip->i_eattr) { - ret = gfs2_ea_dealloc(ip); - if (ret) - goto out_unlock; - } - - if (!gfs2_is_stuffed(ip)) { - ret = gfs2_file_dealloc(ip); - if (ret) - goto out_unlock; - } - - /* We're about to clear the bitmap for the dinode, but as soon as we - do, gfs2_create_inode can create another inode at the same block - location and try to set gl_object again. We clear gl_object here so - that subsequent inode creates don't see an old gl_object. */ - glock_clear_object(ip->i_gl, ip); - ret = gfs2_dinode_dealloc(ip); - gfs2_inode_remember_delete(ip->i_gl, ip->i_no_formal_ino); + ret = evict_unlinked_inode(inode); goto out_unlock; out_truncate: |