Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3083571pxb; Mon, 18 Oct 2021 07:56:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjJfDUoa2k1IVEMORwLnlSV2riItY9M1IYaEFQYFsAkhw9+gzT/aJ4OZzxaM8eskW0pKxl X-Received: by 2002:a17:906:2295:: with SMTP id p21mr30802703eja.421.1634569009124; Mon, 18 Oct 2021 07:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634569009; cv=none; d=google.com; s=arc-20160816; b=ej2REA/LhVXsnb4TyrWgocLmt/KeYlb0bbiOdEHPD9xWdLI+VzImmbkiY77kxVSV9m xH5It3/bLfk21LJShyyjuo4zg6qj7YxPVFEXPcw8MbAzUI6TjuuaeYvQDHyU1jS3mjOq 7pTibG8YMmpoVbFbzogeXmtdUrn/qaBYOGdARawrWQ9/7FLUVS3o20M0hH9P7xjhOacz sNj5PuVAZzI+Zwi1B0ThSCo46M6lO+p7Nvdn31ldJftET9SgWM08Bfdk5pWL/EdDfAPw d9dTVtuuei2097Nhoq5S97TN4LkMBrXtD0FK2QUmePfGrkPgb4HZl0ZvziiqF5iVMjR2 Fr6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=SB5Ii7xfPTM4p2eEWvijuPkly8hQ6NZB0idEsu0sEO8=; b=VQo8LM+GwyKvRLCKprroRXG0Cjb/gGC2XgQurVevB9Q7hJRPC/x9sCM2VgH9/4W+UJ WG0xYlK4C6R3/bEyjBHTklkT0R0tjrqKpyHWkTfT+RvqYnJ9le09jpcO+ydC3o5DSVGg Ghdwsh2LdCy1HcXsLmY5+wrJieBVeNjY9x/UBBzmUVms4oJRc0m8mr7xM3aA51s0RYo0 Ml1mVQjrNO15sTjlZe8171VHY1hHEaj2rU1Nix2pwUpBoIC96rzsmTYd7CsOh+neiM6X S0HjENhtGDoav5wA0HZVfidaYb+u8igqbZh7a1F+/GINWQYMxTSFXJ/+eLhlkxbIAuTW Qyig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cPJmdwkB; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j20si19165763edj.2.2021.10.18.07.56.23; Mon, 18 Oct 2021 07:56:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cPJmdwkB; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232938AbhJRO62 (ORCPT + 99 others); Mon, 18 Oct 2021 10:58:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24943 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232946AbhJRO61 (ORCPT ); Mon, 18 Oct 2021 10:58:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634568976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SB5Ii7xfPTM4p2eEWvijuPkly8hQ6NZB0idEsu0sEO8=; b=cPJmdwkBsy33nEuPfLa0HSBQEldRf1E1Qccx4Pe6hdxw0ksT027zt2wPyLOjYSzNCbm40e OzRPdErvPnKpZvaqZYWHyaEBqINDNZh0yDsO8HwNS7HUfPsNSmePuTYROhrqU3kcENLJUh IOmeCh+hj/aq1Wy8iuWfNtscMbKnwfA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-135-WzAoXm61Pnm4_oBBDiJ4qA-1; Mon, 18 Oct 2021 10:56:12 -0400 X-MC-Unique: WzAoXm61Pnm4_oBBDiJ4qA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A73701006AA2; Mon, 18 Oct 2021 14:56:10 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 388E85BB12; Mon, 18 Oct 2021 14:56:02 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 21/67] cachefiles: Prevent inode from going away when burying a dentry From: David Howells To: linux-cachefs@redhat.com Cc: dhowells@redhat.com, Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , Jeff Layton , Matthew Wilcox , Alexander Viro , Omar Sandoval , Linus Torvalds , linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 18 Oct 2021 15:56:01 +0100 Message-ID: <163456896131.2614702.10188463290568833365.stgit@warthog.procyon.org.uk> In-Reply-To: <163456861570.2614702.14754548462706508617.stgit@warthog.procyon.org.uk> References: <163456861570.2614702.14754548462706508617.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org When deleting a file, we want to make sure that the inode doesn't get detached from it (leading to ->d_inode being cleared) as we may still want to touch the inode afterwards (we want to clear the belongs-to-kernel flag and we may have the dentry referred to by a file struct). Do this by getting an extra ref on the dentry around the vfs_unlink() call so that d_delete() doesn't see the refcount == 1. Signed-off-by: David Howells --- fs/cachefiles/namei.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index 4bd31be3be30..04c767624e3d 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -106,7 +106,9 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache, cachefiles_io_error(cache, "Unlink security error"); } else { trace_cachefiles_unlink(object, rep, why); + dget(rep); ret = vfs_unlink(&init_user_ns, d_inode(dir), rep, NULL); + dput(rep); } inode_unlock(d_inode(dir));