Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp662139pxj; Fri, 14 May 2021 12:25:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIB+RW2KdcgS81EM13KK8iqVtbJozYPVdOPRXDkzOYajzm7s1CnVKF3r2Lec7pof8r3inZ X-Received: by 2002:a05:6402:2064:: with SMTP id bd4mr21170103edb.96.1621020356265; Fri, 14 May 2021 12:25:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621020356; cv=none; d=google.com; s=arc-20160816; b=iHobkWF5/Lhit+dK8QnRLwwnPQp6tRtHFGXiMEENfAAVmNJl1e8w7+OjkPYEY0sZxt XQdURSnSww44rr14eh7tKhUavXW3MBuw5BIPM+j0fzvX1EL/KVdh5SK+nCxBPgTLp48I 0txEuKeySB/yzmuGpGPqfaxulYh9L57i996qvAEKvvNkWskUxDQk9UJEqkPYiZ+jpmS2 HM6alrS5ypPn4ksCfYFcP7wKaydlIBqGKKzKTursF5I9ezH+ZtAfof8BI0+KUGcDIQwN sBqzefPcktNoYFA2DvBRH7hUAEWzufU0/ndQI8Jx+cI2nzoThYF731ZJB5tYWt6PYcw0 NNwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=TElZ39jNcO2LJTaKYUU6wB8bWKMJE1ItSdc7s14/Lfw=; b=S/Kwt2bXn6H7Q9TA7nigwdmE2aVTkEdB6BtWSCpMEUphpuW7/qjLSgNXHwJ36Y4Q1a LFEJIn5JZ3+snStAjbfystlvSopRk4b0vHpOaQISQqOuOB9HZxw8FZb5AQc8aLQ7Kaub 2oIhttDQo2+ZKbvZpLTrDgdwoo0X0X3i6T9nCjTcJ5Pnp4ATQmRhyTjDVH0uC4zzW5Ym U/nGwiA4gxt18jAnniHwbFF3qJYOTQaG0JvOFhBPq8qFFkOsMmnnckTr77Sd+uS+Y6An ZWkSlQ4Vndg0ej59bPGs1GWfGw8MxcgzRMxio+DUz6co0+TYYa6d5PEFYupBnPwrEdJL fPKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=t3u7+v8E; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e23si6781276ejh.183.2021.05.14.12.25.29; Fri, 14 May 2021 12:25:56 -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=@fieldses.org header.s=default header.b=t3u7+v8E; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230157AbhENPKx (ORCPT + 99 others); Fri, 14 May 2021 11:10:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbhENPKx (ORCPT ); Fri, 14 May 2021 11:10:53 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8AC0C061574 for ; Fri, 14 May 2021 08:09:41 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id B25FD449B; Fri, 14 May 2021 11:09:39 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org B25FD449B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1621004979; bh=TElZ39jNcO2LJTaKYUU6wB8bWKMJE1ItSdc7s14/Lfw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=t3u7+v8EERP2ZZYeZjw3oshI5V+C0dAfEusao6qqjrt8qf0nrCwh+jPvtmz2DS/ml jijP5yKQjZ+sL+LY0NYo4ExqoQiPGjGJakl6UsoJtr48RRri9hc2bjGj4FcNh6d72N Vzf9mi4zgPOFnqg+cAy4uADzo8gpM51r33vT37FQ= Date: Fri, 14 May 2021 11:09:39 -0400 From: "J. Bruce Fields" To: Nick Huang Cc: chuck.lever@oracle.com, linux-nfs@vger.kernel.org, Bing Jing Chang , Robbie Ko Subject: Re: [PATCH] nfsd: Prevent truncation of an unlinked inode from blocking access to its directory Message-ID: <20210514150939.GE9256@fieldses.org> References: <20210514035829.5230-1-nickhuang@synology.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210514035829.5230-1-nickhuang@synology.com> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, May 14, 2021 at 11:58:29AM +0800, Nick Huang wrote: > From: Yu Hsiang Huang > > Truncation of an unlinked inode may take a long time for I/O waiting, and > it doesn't have to prevent access to the directory. Thus, let truncation > occur outside the directory's mutex, just like do_unlinkat() does. Makes sense to me, thanks. I'll queue it up for 5.14. Just out of curiosity: was this found just by inspection, or were you hitting this in a real workload? I'd be interested in what it took to reproduce if so. --b. > > Signed-off-by: Yu Hsiang Huang > Signed-off-by: Bing Jing Chang > Signed-off-by: Robbie Ko > --- > fs/nfsd/vfs.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c > index 15adf1f6ab21..39948f130712 100644 > --- a/fs/nfsd/vfs.c > +++ b/fs/nfsd/vfs.c > @@ -1859,6 +1859,7 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, > { > struct dentry *dentry, *rdentry; > struct inode *dirp; > + struct inode *rinode; > __be32 err; > int host_err; > > @@ -1887,6 +1888,8 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, > host_err = -ENOENT; > goto out_drop_write; > } > + rinode = d_inode(rdentry); > + ihold(rinode); > > if (!type) > type = d_inode(rdentry)->i_mode & S_IFMT; > @@ -1902,6 +1905,8 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, > if (!host_err) > host_err = commit_metadata(fhp); > dput(rdentry); > + fh_unlock(fhp); > + iput(rinode); /* truncate the inode here */ > > out_drop_write: > fh_drop_write(fhp); > -- > 2.25.1