]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
libxfs: pass IGET flags through to xfs_iread
authorDarrick J. Wong <djwong@kernel.org>
Wed, 3 Jul 2024 21:21:32 +0000 (14:21 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 31 Jul 2024 01:46:41 +0000 (18:46 -0700)
Change the lock_flags parameter to iget_flags so that we can supply
XFS_IGET_ flags in future patches.  All callers of libxfs_iget and
libxfs_trans_iget pass zero for this parameter and there are no inode
locks in xfsprogs, so there's no behavior change here.

Port the kernel's version of the xfs_inode_from_disk callsite.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
libxfs/inode.c

index fffca776153186665c73f7bc2a88aa503ee6653e..2af7e8fe9001878beaa908ed29b39911389b896b 100644 (file)
@@ -298,11 +298,10 @@ libxfs_iget(
        struct xfs_mount        *mp,
        struct xfs_trans        *tp,
        xfs_ino_t               ino,
-       uint                    lock_flags,
+       uint                    flags,
        struct xfs_inode        **ipp)
 {
        struct xfs_inode        *ip;
-       struct xfs_buf          *bp;
        struct xfs_perag        *pag;
        int                     error = 0;
 
@@ -327,18 +326,35 @@ libxfs_iget(
        if (error)
                goto out_destroy;
 
-       error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp);
-       if (error)
-               goto out_destroy;
+       /*
+        * For version 5 superblocks, if we are initialising a new inode and we
+        * are not utilising the XFS_MOUNT_IKEEP inode cluster mode, we can
+        * simply build the new inode core with a random generation number.
+        *
+        * For version 4 (and older) superblocks, log recovery is dependent on
+        * the di_flushiter field being initialised from the current on-disk
+        * value and hence we must also read the inode off disk even when
+        * initializing new inodes.
+        */
+       if (xfs_has_v3inodes(mp) &&
+           (flags & XFS_IGET_CREATE) && !xfs_has_ikeep(mp)) {
+               VFS_I(ip)->i_generation = get_random_u32();
+       } else {
+               struct xfs_buf          *bp;
 
-       error = xfs_inode_from_disk(ip,
-                       xfs_buf_offset(bp, ip->i_imap.im_boffset));
-       if (!error)
-               xfs_buf_set_ref(bp, XFS_INO_REF);
-       xfs_trans_brelse(tp, bp);
+               error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp);
+               if (error)
+                       goto out_destroy;
 
-       if (error)
-               goto out_destroy;
+               error = xfs_inode_from_disk(ip,
+                               xfs_buf_offset(bp, ip->i_imap.im_boffset));
+               if (!error)
+                       xfs_buf_set_ref(bp, XFS_INO_REF);
+               xfs_trans_brelse(tp, bp);
+
+               if (error)
+                       goto out_destroy;
+       }
 
        *ipp = ip;
        return 0;