Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3066037ybb; Mon, 6 Apr 2020 01:04:24 -0700 (PDT) X-Google-Smtp-Source: APiQypK6TkVSRiSo7ngd/q5t6scYijSaNZOID1JZKznFUgHxkjzu3sIUGPCR4J1XrravJbK+6mHY X-Received: by 2002:a9d:7a7:: with SMTP id 36mr17207771oto.283.1586160264800; Mon, 06 Apr 2020 01:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586160264; cv=none; d=google.com; s=arc-20160816; b=MIXI9lTVdHQ+TAEnNfM8lHAAQqDIiTWyejvFFDK4W2amQ7r4Qgb9hzBGkl/OUA/WZY 6hlWjgbtGci3LznXb3PFgQo8ezd08sxksTCDjvV+wy2p+sDCMUAxoVcQHf22TaBoJjo3 jTfzZ20px6PTFYWrbYfE1zPtGjePMssCwkHSz3oFZjnYrAAZ2F1BDpKUnWQqM8bcjLur yexzvkEHazuXH7qyI/y/CFY2AVK6wCWJBZ3TrgyQ6W0Ny3spILZOv8uGybPK4zisZNyI Mf7O3EJUjgDTX/yVwn788YPPWoHsxoAFUOeRnrF087VnJeEfAzk9ffBw5FU9xQ6yq5sA SxHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=cx1EgmAgHDuZk6te/lX8h6DcjrJUlz5PmyQsx6YhCgg=; b=j2Zt+FedUzHGnoR6ykCAiZ9yQYng03yYFDrLxklN7vzygv3yEM6yREjnlrhiPOnjG8 rJnHUQz4bISEr5U8DH8wJh3d7tm+2MO0qG0KI2EuHNw83EPGZG3swfcok3E+5aPe7/q5 Mj0s6+/+ICxhZkLfzNz1uXRM8X2IYBAIiJpnTtdFV7eaOzpOkYZC7108NI2rr10EvteD /+1XdgNC6+TSHEfJNZtoIVf58ml3KjeUviveoZHvUn6XRgqgggLcNdW2V0bYDXLN6vIP JkgTxD90wGuxOrMKtTRw2csuHUGLY0XunRE1RYM0kM0xvRBrhF8bB734WrBaFnjp75Bi XAjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p187si7497443oop.28.2020.04.06.01.04.12; Mon, 06 Apr 2020 01:04:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726559AbgDFIDN (ORCPT + 99 others); Mon, 6 Apr 2020 04:03:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:60480 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726475AbgDFIDM (ORCPT ); Mon, 6 Apr 2020 04:03:12 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 67FFCAE0A; Mon, 6 Apr 2020 08:03:10 +0000 (UTC) Date: Mon, 6 Apr 2020 10:03:05 +0200 From: Anthony Iliopoulos To: Christoph Hellwig Cc: Sagi Grimberg , Chaitanya Kulkarni , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] nvmet: add revalidation support to bdev and file backed namespaces Message-ID: <20200406080305.GA1329@technoir> References: <20200402193052.19935-1-ailiop@suse.com> <20200403064331.GA23270@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200403064331.GA23270@lst.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 03, 2020 at 08:43:31AM +0200, Christoph Hellwig wrote: > On Thu, Apr 02, 2020 at 09:30:52PM +0200, Anthony Iliopoulos wrote: > > Add support for detecting capacity changes on nvmet blockdev and file > > backed namespaces. This allows for emulating and testing online resizing > > of nvme devices and filesystems on top. > > > > Signed-off-by: Anthony Iliopoulos > > I vaguely remember seeing a very similar patch before, is this a repost? Not a repost, but you're right, apparently there was a similar patch posted before: 20191008122904.20438-1-m.malygin@yadro.com, which instead triggers revalidation via configfs. > > +void nvmet_bdev_ns_revalidate(struct nvmet_ns *ns) > > +{ > > + loff_t size; > > + > > + size = i_size_read(ns->bdev->bd_inode); > > + > > + if (ns->size != size) > > + ns->size = size; > > This can be: > > ns->size = i_size_read(ns->bdev->bd_inode); Fixed. > > +void nvmet_file_ns_revalidate(struct nvmet_ns *ns) > > +{ > > + struct kstat stat; > > + > > + if (!ns->file) > > + return; > > Shouldn't this always be non-NULL? Right, this would be unset only during nvmet_ns_disable, and by that time the ns is off the list, so identify should never see this being non-NULL. Removed. > > + > > + if (vfs_getattr(&ns->file->f_path, > > + &stat, STATX_SIZE, AT_STATX_FORCE_SYNC)) > > + return; > > Use up the full line: > > if (vfs_getattr(&ns->file->f_path, &stat, STATX_SIZE, > AT_STATX_FORCE_SYNC)) Fixed. > Also shouldn't there be error handling? If we can't stat the file > the namespace is toast. Indeed, I think it makes sense to fail identify at that point with NVME_SC_INVALID_NS. If you'd rather go with this patch instead of the configfs approach, I'll post a v2 with the fixes, and some associated blktests that Chaitanya requested. Thank you all for the reviews!