Check for unlinked znodes after igrab()

The changes in commit 41e1aa2a / PR #9583 introduced a regression on
tmpfile_001_pos: fsetxattr() on a O_TMPFILE file descriptor started
to fail with errno ENODATA:

    openat(AT_FDCWD, "/test", O_RDWR|O_TMPFILE, 0666) = 3
    <...>
    fsetxattr(3, "user.test", <...>, 64, 0) = -1 ENODATA

The originally proposed change on PR #9583 is not susceptible to it,
so just move the code/if-checks around back in that way, to fix it.

Reviewed-by: Pavel Snajdr <snajpa@snajpa.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Original-patch-by: Heitor Alves de Siqueira <halves@canonical.com>
Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
Closes #9602
This commit is contained in:
Mauricio Faria de Oliveira 2019-11-21 17:24:03 -03:00 committed by Tony Hutter
parent 6fed191975
commit bc21c56c2d

View File

@ -1094,7 +1094,8 @@ again:
ASSERT3U(zp->z_id, ==, obj_num); ASSERT3U(zp->z_id, ==, obj_num);
/* /*
* If zp->z_unlinked is set, the znode is already marked * If zp->z_unlinked is set, the znode is already marked
* for deletion and should not be discovered. * for deletion and should not be discovered. Check this
* after checking igrab() due to fsetxattr() & O_TMPFILE.
* *
* If igrab() returns NULL the VFS has independently * If igrab() returns NULL the VFS has independently
* determined the inode should be evicted and has * determined the inode should be evicted and has
@ -1109,9 +1110,10 @@ again:
* need to detect the active SA hold thereby informing * need to detect the active SA hold thereby informing
* the VFS that this inode should not be evicted. * the VFS that this inode should not be evicted.
*/ */
if (zp->z_unlinked) { if (igrab(ZTOI(zp)) == NULL) {
if (zp->z_unlinked)
err = SET_ERROR(ENOENT); err = SET_ERROR(ENOENT);
} else if (igrab(ZTOI(zp)) == NULL) { else
err = SET_ERROR(EAGAIN); err = SET_ERROR(EAGAIN);
} else { } else {
*zpp = zp; *zpp = zp;