From owner-freebsd-fs@freebsd.org Mon Dec 19 23:32:39 2016 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E203BC88A5C for ; Mon, 19 Dec 2016 23:32:39 +0000 (UTC) (envelope-from 01000159196dee7c-b727d595-c8e6-4761-b2a7-197d27f1f21a-000000@amazonses.com) Received: from a8-237.smtp-out.amazonses.com (a8-237.smtp-out.amazonses.com [54.240.8.237]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A17841DC3 for ; Mon, 19 Dec 2016 23:32:39 +0000 (UTC) (envelope-from 01000159196dee7c-b727d595-c8e6-4761-b2a7-197d27f1f21a-000000@amazonses.com) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=vnqrkfnvu6csdl6mwgk5t6ix3nnepx57; d=tarsnap.com; t=1482190352; h=Subject:To:References:Cc:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=SxMHYMInz3sByjUr5+aWscY2rnzqaaTsSiWSGuozOAg=; b=U4kFNYriMQs+mGKFD+gdEoc2o9JExz93PfulMFWa1yl60P+VK3E302b+XGz+fSFD kLpCnjfu77KQE99BJSd5JySvG1j+iDbF+6cw4lg8mUJ0ZmXOkcjze7sYTmiFudNH685 EWXq5ebECt6o7c3uJ/rweALQyP4DOhuWnPahtKeg= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw; d=amazonses.com; t=1482190352; h=Subject:To:References:Cc:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding:Feedback-ID; bh=SxMHYMInz3sByjUr5+aWscY2rnzqaaTsSiWSGuozOAg=; b=fE054Jy0jSVEuUb/PNaGZ3Yzsv+FLOAcIYFWOKJcRmHTDjXHgwoJ9ZWa3s+veltI 4xBNrkRQhtNadysoC8V50DuhqP2/OK1uL7AcpmFcijGxpGVM7AynioTBV6IoMeo0VIr yLb/dFr9QsdvzkrBbaHLi8gRqexEz4/jMWSM6k1Q= Subject: Re: ESTALE after cwd deleted by same NFS client To: Rick Macklem References: <01000158f023675b-41b35a73-4428-4937-853b-62db4fb9b984-000000@email.amazonses.com> <20161212054233.GU8460@kduck.kaduk.org> <01000158f1abc081-d4eddc58-3b4b-41dd-aa1e-0157d2fad812-000000@email.amazonses.com> <20161212163603.GV8460@kduck.kaduk.org> <01000158fc3da2c5-c13da088-e7b9-4ac0-ac01-ec49a275dd24-000000@email.amazonses.com> <010001590945e9b3-015a4d05-2646-44ba-9db9-415e8b9119dd-000000@email.amazonses.com> <0100015915a5ee96-49de6100-5050-4a0a-a3c9-1bd4215bc6a0-000000@email.amazonses.com> Cc: "freebsd-fs@freebsd.org" From: Colin Percival Message-ID: <01000159196dee7c-b727d595-c8e6-4761-b2a7-197d27f1f21a-000000@email.amazonses.com> Date: Mon, 19 Dec 2016 23:32:32 +0000 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SES-Outgoing: 2016.12.19-54.240.8.237 Feedback-ID: 1.us-east-1.Lv9FVjaNvvR5llaqfLoOVbo2VxOELl7cjN0AOyXnPlk=:AmazonSES X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Dec 2016 23:32:40 -0000 On 12/19/16 13:59, Rick Macklem wrote: > Colin Percival wrote: >> Further information: In addition to the "lookup relative to a directory which >> has been deleted out from underneath us" case which causes ESTALE to land in >> nfs_lookup, the cleandir step of buildworld results in ESTALE being returned >> by nfsrpc_getattr into nfs_getattr (landing ultimately in getcwd), and ESTALE >> being returned by nfsrpc_accessrpc into nfs34_access_otw (landing ultimately >> in stat and lstat). >> >> In UFS there are checks for effnlink == 0 which result in e.g. ufs_lookup >> returning ENOENT; would it make sense to add NREMOVED to struct nfsnode.n_flag >> and check this in the appropriate nfs_* calls? > To be honest, I can't think of a reason why userland would ever want to see ESTALE? > The function you see above "nfscl_maperr()" could easily map all ESTALEs to ENOENTs? I was wondering about that. I hesitated to suggest it since it seemed like doing this could mask bugs and/or throw away useful information -- I mean, I assume there was a reason ESTALE existed in the first place... > - The question is: "Would returning ENOENT for stat(2) and access(2) actually make the > buildworld happy? I think buildworld would need s/ESTALE/ENOENT/ in access, lstat, rmdir, stat, and unlink. But with those I'm 99% confident that buildworld will complete. > --> The cheat for regular files is "sillyrename". This could be done for directories, > but there are multiple comments in the code (not put there by me) that say > "no sillyrename for directories". > #1 Does this imply something breaks when you do sillyrename for dirs? Yes. You'd run into this scenario: $ mkdir /nfs/foo $ cd /nfs/foo $ rmdir /nfs/foo # still in use, sillyrename happens $ touch bar # creates /nfs/foo.sillyname/bar $ cd / # directory no longer in use, time to delete it... Whereas keeping track of "this nfsnode refers to a directory which has been deleted" would allow us to return ENOENT to file-creation attempt, just like UFS does if you try to create a file inside a removed directory. -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid