From patchwork Mon May 15 14:39:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 762551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wRNX95JVJz9s03 for ; Tue, 16 May 2017 00:39:53 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kkj7+glJ"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Date:Message-ID:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=vVL3LnSRNU8WZKwPnbBM6Mk4g16eK8bIUJNbsNllHzE=; b=kkj7+glJ0d+MPs lyBFXT/feI6E4RfXiSlS+pdxceX/xh5jwVrX5Ds/W75TfB0nPdhYdFPTVREVgvdf2c8SBuYeGMxso Xo0KZPti2w7d/IkfwY5SUTnuvQqpL8HU/jkeu6dXiL0cDo1XE/m10t2aG1mFVOWNkK7C2NWpKu7Ji FGVoYUpFVLf8BgkdVLbOpAumrD9/PDaKRt0HOwUSXW4hGPXDHjVsmKMUFEF5/YATJK7/iRa4GzBC1 fhVk/mSEP853ZUXiMBpyw5Ck0ISkMvvT8XeyvvuHE/re8O++4y9kbFCkN6JYcNgDK/EWlYnMbA4Ia N2goBiew2MUQboAIIGtQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dAHA7-0001Dl-1u; Mon, 15 May 2017 14:39:51 +0000 Received: from b.ns.miles-group.at ([95.130.255.144] helo=radon.swed.at) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dAHA3-0000vS-HS for linux-mtd@lists.infradead.org; Mon, 15 May 2017 14:39:49 +0000 Received: (qmail 26781 invoked by uid 89); 15 May 2017 14:39:24 -0000 Received: by simscan 1.3.1 ppid: 26776, pid: 26779, t: 0.0389s scanners: attach: 1.3.1 Received: from unknown (HELO ?10.1.1.177?) (richard@nod.at@82.150.214.13) by radon.swed.at with ESMTPA; 15 May 2017 14:39:24 -0000 From: Richard Weinberger To: linux-fscrypt@vger.kernel.org Subject: Question on fscrypt_d_revalidate() and fstest generic/429 Message-ID: Date: Mon, 15 May 2017 16:39:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170515_073947_898938_10EFC8E4 X-CRM114-Status: GOOD ( 12.54 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [95.130.255.144 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gstir , Theodore Ts'o , Eric Biggers , Artem Bityutskiy , "linux-kernel@vger.kernel.org" , Adrian Hunter , "linux-mtd@lists.infradead.org" , Al Viro , linux-fsdevel , David Oberhollenzer Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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: 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 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; }