gfs2: Move gfs2_dinode_dealloc
authorAndreas Gruenbacher <agruenba@redhat.com>
Thu, 17 Apr 2025 20:41:40 +0000 (22:41 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Mon, 21 Apr 2025 16:20:36 +0000 (18:20 +0200)
Move gfs2_dinode_dealloc() and its helper gfs2_final_release_pages()
from super.c to inode.c.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/inode.c
fs/gfs2/inode.h
fs/gfs2/super.c

index 62ff09264f0fdf1c473db0af601982302b9b0013..0b2d75106b1cfdfda41528cf4a196fd3e02e917e 100644 (file)
@@ -439,6 +439,74 @@ out:
        return error;
 }
 
+static void gfs2_final_release_pages(struct gfs2_inode *ip)
+{
+       struct inode *inode = &ip->i_inode;
+       struct gfs2_glock *gl = ip->i_gl;
+
+       if (unlikely(!gl)) {
+               /* This can only happen during incomplete inode creation. */
+               BUG_ON(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags));
+               return;
+       }
+
+       truncate_inode_pages(gfs2_glock2aspace(gl), 0);
+       truncate_inode_pages(&inode->i_data, 0);
+
+       if (atomic_read(&gl->gl_revokes) == 0) {
+               clear_bit(GLF_LFLUSH, &gl->gl_flags);
+               clear_bit(GLF_DIRTY, &gl->gl_flags);
+       }
+}
+
+int gfs2_dinode_dealloc(struct gfs2_inode *ip)
+{
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
+       struct gfs2_rgrpd *rgd;
+       struct gfs2_holder gh;
+       int error;
+
+       if (gfs2_get_inode_blocks(&ip->i_inode) != 1) {
+               gfs2_consist_inode(ip);
+               return -EIO;
+       }
+
+       gfs2_rindex_update(sdp);
+
+       error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
+       if (error)
+               return error;
+
+       rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1);
+       if (!rgd) {
+               gfs2_consist_inode(ip);
+               error = -EIO;
+               goto out_qs;
+       }
+
+       error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE,
+                                  LM_FLAG_NODE_SCOPE, &gh);
+       if (error)
+               goto out_qs;
+
+       error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA,
+                                sdp->sd_jdesc->jd_blocks);
+       if (error)
+               goto out_rg_gunlock;
+
+       gfs2_free_di(rgd, ip);
+
+       gfs2_final_release_pages(ip);
+
+       gfs2_trans_end(sdp);
+
+out_rg_gunlock:
+       gfs2_glock_dq_uninit(&gh);
+out_qs:
+       gfs2_quota_unhold(ip);
+       return error;
+}
+
 static void gfs2_init_dir(struct buffer_head *dibh,
                          const struct gfs2_inode *parent)
 {
index 9e5e1622d50a606777ae7ca4890f182f26cec9ff..eafe123617e6980ab1494e2bfc9e7fc0fe941249 100644 (file)
@@ -92,6 +92,7 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type,
 struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr,
                                  u64 no_formal_ino,
                                  unsigned int blktype);
+int gfs2_dinode_dealloc(struct gfs2_inode *ip);
 
 struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
                           int is_root);
index 4529b7dda8ca2e285fdd42131a28f4fa400762a5..3f49f848c6b4e0020960978ec17726f4bb812849 100644 (file)
@@ -1173,74 +1173,6 @@ static int gfs2_show_options(struct seq_file *s, struct dentry *root)
        return 0;
 }
 
-static void gfs2_final_release_pages(struct gfs2_inode *ip)
-{
-       struct inode *inode = &ip->i_inode;
-       struct gfs2_glock *gl = ip->i_gl;
-
-       if (unlikely(!gl)) {
-               /* This can only happen during incomplete inode creation. */
-               BUG_ON(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags));
-               return;
-       }
-
-       truncate_inode_pages(gfs2_glock2aspace(gl), 0);
-       truncate_inode_pages(&inode->i_data, 0);
-
-       if (atomic_read(&gl->gl_revokes) == 0) {
-               clear_bit(GLF_LFLUSH, &gl->gl_flags);
-               clear_bit(GLF_DIRTY, &gl->gl_flags);
-       }
-}
-
-static int gfs2_dinode_dealloc(struct gfs2_inode *ip)
-{
-       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
-       struct gfs2_rgrpd *rgd;
-       struct gfs2_holder gh;
-       int error;
-
-       if (gfs2_get_inode_blocks(&ip->i_inode) != 1) {
-               gfs2_consist_inode(ip);
-               return -EIO;
-       }
-
-       gfs2_rindex_update(sdp);
-
-       error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
-       if (error)
-               return error;
-
-       rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1);
-       if (!rgd) {
-               gfs2_consist_inode(ip);
-               error = -EIO;
-               goto out_qs;
-       }
-
-       error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE,
-                                  LM_FLAG_NODE_SCOPE, &gh);
-       if (error)
-               goto out_qs;
-
-       error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA,
-                                sdp->sd_jdesc->jd_blocks);
-       if (error)
-               goto out_rg_gunlock;
-
-       gfs2_free_di(rgd, ip);
-
-       gfs2_final_release_pages(ip);
-
-       gfs2_trans_end(sdp);
-
-out_rg_gunlock:
-       gfs2_glock_dq_uninit(&gh);
-out_qs:
-       gfs2_quota_unhold(ip);
-       return error;
-}
-
 /**
  * gfs2_glock_put_eventually
  * @gl:        The glock to put