All of lore.kernel.org
 help / color / mirror / Atom feed
* Question on fscrypt_d_revalidate() and fstest generic/429
@ 2017-05-15 14:39 Richard Weinberger
  2017-05-15 19:45 ` Eric Biggers
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Weinberger @ 2017-05-15 14:39 UTC (permalink / raw)
  To: linux-fscrypt
  Cc: linux-fsdevel, Eric Biggers, Theodore Ts'o, Al Viro,
	David Gstir, David Oberhollenzer, linux-kernel, linux-mtd,
	Artem Bityutskiy, Adrian Hunter

Hi!

on UBIFS, fstest generic/429 fails due to -ENFILE because the internal orphan
list reaches the maximum size.
When you unlink a file, the inode goes into the orphan list, in UBIFS' evict() function
it is being removed later. So, only unlinked but used inodes should stay in that list.

If a directory is encrypted, evict() is not being called although the inode has no
users anymore.
It turned out evict() is not being called because fscrypt's fscrypt_d_revalidate()
function.
When I omit fscrypt_set_d_op() in UBIFS code, the test works just fine.

Can it be that fscrypt_d_revalidate() misses the case of i_nlink being 0?
It seem to treat unlinked inodes as already gone and they stay.

The following change makes the problem go away here:

diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index 6d6eca394d4d..d0c19838e513 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -327,6 +327,7 @@ EXPORT_SYMBOL(fscrypt_decrypt_page);
 static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags)
 {
        struct dentry *dir;
+       struct inode *inode = d_inode(dentry);
        int dir_has_key, cached_with_key;

        if (flags & LOOKUP_RCU)
@@ -359,6 +360,10 @@ static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags)
                        (!cached_with_key && dir_has_key) ||
                        (cached_with_key && !dir_has_key))
                return 0;
+
+       if (!inode || inode->i_nlink == 0)
+               return 0;
+
        return 1;
 }

Does this change make sense? TBH, I'm not really an expert in this area and it is also
not clear to me why you don't see these issue on ext4 or f2fs.
Maybe UBIFS' limitations kick in much earlier. ;-)

Thanks,
//richard

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-05-16 22:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-15 14:39 Question on fscrypt_d_revalidate() and fstest generic/429 Richard Weinberger
2017-05-15 19:45 ` Eric Biggers
2017-05-15 19:51   ` Richard Weinberger
2017-05-15 23:25     ` Eric Biggers
2017-05-16  6:47       ` Richard Weinberger
2017-05-16 22:07         ` Eric Biggers
2017-05-16 22:27           ` Richard Weinberger
2017-05-15 23:50     ` Al Viro
2017-05-16 11:22       ` Richard Weinberger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.