gfs2: Move GIF_ALLOC_FAILED check out of gfs2_ea_dealloc
authorAndreas Gruenbacher <agruenba@redhat.com>
Thu, 17 Apr 2025 23:09:32 +0000 (01:09 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Mon, 21 Apr 2025 16:20:36 +0000 (18:20 +0200)
Don't check for the GIF_ALLOC_FAILED flag in gfs2_ea_dealloc() and pass
that information explicitly instead.  This allows for a cleaner
follow-up patch.

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

index 3f49f848c6b4e0020960978ec17726f4bb812849..e25a24ae2197fd28c3052b1ce9eca36eba7d4fa1 100644 (file)
@@ -1314,7 +1314,7 @@ static int evict_unlinked_inode(struct inode *inode)
        }
 
        if (ip->i_eattr) {
-               ret = gfs2_ea_dealloc(ip);
+               ret = gfs2_ea_dealloc(ip, !test_bit(GIF_ALLOC_FAILED, &ip->i_flags));
                if (ret)
                        goto out;
        }
index 17ae5070a90e67d3e8f3cb2fbdd8e6e538d1a524..df9c93de94c793c2d6d70950428be0f042d891ed 100644 (file)
@@ -1383,7 +1383,7 @@ out:
        return error;
 }
 
-static int ea_dealloc_block(struct gfs2_inode *ip)
+static int ea_dealloc_block(struct gfs2_inode *ip, bool initialized)
 {
        struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct gfs2_rgrpd *rgd;
@@ -1416,7 +1416,7 @@ static int ea_dealloc_block(struct gfs2_inode *ip)
        ip->i_eattr = 0;
        gfs2_add_inode_blocks(&ip->i_inode, -1);
 
-       if (likely(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags))) {
+       if (initialized) {
                error = gfs2_meta_inode_buffer(ip, &dibh);
                if (!error) {
                        gfs2_trans_add_meta(ip->i_gl, dibh);
@@ -1435,11 +1435,12 @@ out_gunlock:
 /**
  * gfs2_ea_dealloc - deallocate the extended attribute fork
  * @ip: the inode
+ * @initialized: xattrs have been initialized
  *
  * Returns: errno
  */
 
-int gfs2_ea_dealloc(struct gfs2_inode *ip)
+int gfs2_ea_dealloc(struct gfs2_inode *ip, bool initialized)
 {
        int error;
 
@@ -1451,7 +1452,7 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip)
        if (error)
                return error;
 
-       if (likely(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags))) {
+       if (initialized) {
                error = ea_foreach(ip, ea_dealloc_unstuffed, NULL);
                if (error)
                        goto out_quota;
@@ -1463,7 +1464,7 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip)
                }
        }
 
-       error = ea_dealloc_block(ip);
+       error = ea_dealloc_block(ip, initialized);
 
 out_quota:
        gfs2_quota_unhold(ip);
index eb12eb7e37c194c8857bcd4de03737ef6b7cfe2a..3c9788e0e13750c0168c2f942f3ba441ffbca333 100644 (file)
@@ -54,7 +54,7 @@ int __gfs2_xattr_set(struct inode *inode, const char *name,
                     const void *value, size_t size,
                     int flags, int type);
 ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size);
-int gfs2_ea_dealloc(struct gfs2_inode *ip);
+int gfs2_ea_dealloc(struct gfs2_inode *ip, bool initialized);
 
 /* Exported to acl.c */