xfs
[Top] [All Lists]

[RFC] libxfs: adding attribute fork frees xfs_inode ptr

To: XFS Mailing List <xfs@xxxxxxxxxxx>
Subject: [RFC] libxfs: adding attribute fork frees xfs_inode ptr
From: Mark Tinguely <tinguely@xxxxxxx>
Date: Wed, 23 Apr 2014 16:04:35 -0500
Delivered-to: xfs@xxxxxxxxxxx
References: <20140423210034.892939354@xxxxxxx>
User-agent: quilt/0.48-20.3.1
User space does not currently perform any attribute adding/deleting,
but if we do want to fix attributes or use them for parent inode
pointers, user space should support attributes.

The adding an attribute fork is done in an embedded transaction
inside xfs_attr_set_int(). The xfs_trans_commit in xfs_bmap_add_attrfork()
will free the xfs_inode pointer causing xfs_attr_calc_size() in
xfs_attr_set_int() to fail.

I don't see that we have any hold counts on the xfs_inode, so this is
a dirty FYI/RFC of a work around for this problem by calling xfs_iget()
to read back in the just freed inode.

---
 libxfs/xfs_attr.c |    4 ++++
 1 file changed, 4 insertions(+)

Index: b/libxfs/xfs_attr.c
===================================================================
--- a/libxfs/xfs_attr.c
+++ b/libxfs/xfs_attr.c
@@ -223,11 +223,15 @@ xfs_attr_set_int(
         * (inode must not be locked when we call this routine)
         */
        if (XFS_IFORK_Q(dp) == 0) {
+               xfs_ino_t       ino = dp->i_ino;
                int sf_size = sizeof(xfs_attr_sf_hdr_t) +
                              XFS_ATTR_SF_ENTSIZE_BYNAME(name->len, valuelen);
 
                if ((error = xfs_bmap_add_attrfork(dp, sf_size, rsvd)))
                        return(error);
+               error = libxfs_iget(mp, NULL, ino, 0, &dp, 0);
+               if (error)
+                       return(error);
        }
 
        /*


<Prev in Thread] Current Thread [Next in Thread>