Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1460531rdb; Wed, 24 Jan 2024 16:52:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUbdGq4fqjGaLK9HrDTtQZDQnw5cfKZWWiCXEjbKONKOog00Gc5X4njfn7sJGU6KjBbhBj X-Received: by 2002:ac2:551d:0:b0:50e:77b1:a3a9 with SMTP id j29-20020ac2551d000000b0050e77b1a3a9mr41152lfk.102.1706143955751; Wed, 24 Jan 2024 16:52:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706143955; cv=pass; d=google.com; s=arc-20160816; b=yPAPyEOYFIy6yTkWJZfqolrEH/pTwmMVLAGkCUSOAkLEXm15wJ1V29AEthEJFHWbI7 qKRrnkqiSX+pMkGVfiMo4iTH3Q2uO3NMKsv+/xF2mQ1PWDp8bcG5RFk/v1MhURySKKvs 3RtFjahYEibEZ6alZcG7C2wK5wCe6Mo8mXV+cjO7yLeUOu4jfbcmnnL8WzrdOmZIpGDX XNpkzwCd8j58eZxjSS6jYpRIWlFcGjbRx7g6yUG1/m8iRO0iu5L73iJv5YZdR87XZ/wA tmQ/gOHeht6gFSTtJLPcv8TrHjnxfqhu7nGK2Ht1WmWexTT3ldfzq74S3QtELbIz5/Kv jRew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=po/0oteFTmQ9rnAeCbF01IarKtBSBYdzRdjPkncGo0s=; fh=vPuI60WcxVNUEUFP7xUmsxGJMsRqI56qlsOB5Rxujgo=; b=nB2i5+ux8mc4/cJQbat8sX+3xVEkhreaR+YXURRweXgvlE/JJdJ+b9yfG/uRFLzsVt 1n+jXELxbpVCh14e01+5DnB6u6ZFaxTsniSxt/ia+6d2QmzT1GvbLG6xpoQZrm4qnsnz 0P53aOooavbK1j3lKGIcq2v6+BMl/az3PeGVB3kg6sXZXJ4FRoF695qzfTtvXExbExB8 SNNaxDWW+mj9mpWsyp55c0XQBVMUBfN9kT7urpKfSGTUlBMP1z9HK+Sn0WNRgemxa0Pv 79GV4xDu9TtE4muIlIelnTkAmBa9tJEUpa9aP58qe8LU/VIKh8MeF+vTjtVPsCrfM7K8 DPyQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kjVf039j; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-37837-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37837-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id z9-20020a1709060ac900b00a310f8dff9asi420720ejf.990.2024.01.24.16.52.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 16:52:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37837-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kjVf039j; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-37837-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37837-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7BB5F1F21E5E for ; Thu, 25 Jan 2024 00:52:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 996F346A4; Thu, 25 Jan 2024 00:52:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kjVf039j" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B17EF193; Thu, 25 Jan 2024 00:52:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706143939; cv=none; b=uoPgycZ6+RW/3scGPqz9qpL9X6hyiXcfmLJ+a7ebI9ncSPxmbMW8ykSZi7YfLM2BV86YIg61ZLSP4AE1jJJchCQixQOm8HGfGqNpNfTSDqrmLpYzFgrsk3oMMvKTswYzCMBaI2BHkzdEJt9BweYUbqBepyn4QDlmqBU4LpjAXec= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706143939; c=relaxed/simple; bh=OC+XjcopZnLmb3krF+LmINeVCFSSzz1GKe4Bd/HF3is=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EfsSGH1+EOKHhba5bWNYBRYtKq5By0yfteYIkJy7eQ6Su0YLKeaF7/4MWnTo+QWOHmEJKfAGSuqgZ126UaJ1juAhhBRIglyv1BaxFQYKKoARFrUrSTljJkerej50QcJB3Sh+c1fMaMOXenUyA6B5RZlZuePf4yhwohXMcOVYaCo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kjVf039j; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC799C433F1; Thu, 25 Jan 2024 00:52:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706143939; bh=OC+XjcopZnLmb3krF+LmINeVCFSSzz1GKe4Bd/HF3is=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kjVf039jecmwPe9R72x3rAlCy7CKTs7nEXwzknpB92pT0W5/sT6udGTVQ1r1ooKkL QzygMx99xtOFMc3xgRjzEjiK+KWse1MhzwiXhemYGRiX8tYKNg8QrmAsy3j4c2v0R2 MG3n1VtEdNMKgyUKQ5qZhb0lvf0cQfJWPcLs5RWaZNvT0nJLMz7b+1jI1i+oY8oMEw DX3Aoi7n6PZuvySPFQic7XTReDwm7uxPykDUoTEr8ORokUt+x2GyV19gA+bKhDYRAb f404L0eJjoURXfAbvQ/nUgC8vpiaVgoUFMq+GyeYm+RXAJCQcF3iwweOPAEx4Z07fw bROl+5bpH/8lA== Date: Wed, 24 Jan 2024 17:52:15 -0700 From: Keith Busch To: John Garry Cc: axboe@kernel.dk, hch@lst.de, sagi@grimberg.me, jejb@linux.ibm.com, martin.petersen@oracle.com, djwong@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, jack@suse.cz, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, linux-scsi@vger.kernel.org, ming.lei@redhat.com, ojaswin@linux.ibm.com, bvanassche@acm.org, Alan Adamson Subject: Re: [PATCH v3 15/15] nvme: Ensure atomic writes will be executed atomically Message-ID: References: <20240124113841.31824-1-john.g.garry@oracle.com> <20240124113841.31824-16-john.g.garry@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240124113841.31824-16-john.g.garry@oracle.com> On Wed, Jan 24, 2024 at 11:38:41AM +0000, John Garry wrote: > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > index 5045c84f2516..6a34a5d92088 100644 > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -911,6 +911,32 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, > if (req->cmd_flags & REQ_RAHEAD) > dsmgmt |= NVME_RW_DSM_FREQ_PREFETCH; > > + /* > + * Ensure that nothing has been sent which cannot be executed > + * atomically. > + */ > + if (req->cmd_flags & REQ_ATOMIC) { > + struct nvme_ns_head *head = ns->head; > + u32 boundary_bytes = head->atomic_boundary; > + > + if (blk_rq_bytes(req) > ns->head->atomic_max) > + return BLK_STS_IOERR; > + > + if (boundary_bytes) { > + u32 mask = boundary_bytes - 1, imask = ~mask; > + u32 start = blk_rq_pos(req) << SECTOR_SHIFT; > + u32 end = start + blk_rq_bytes(req); > + > + if (blk_rq_bytes(req) > boundary_bytes) > + return BLK_STS_IOERR; > + > + if (((start & imask) != (end & imask)) && > + (end & mask)) { > + return BLK_STS_IOERR; > + } > + } > + } Aren't these new fields, atomic_max and atomic_boundary, duplicates of the equivalent queue limits? Let's just use the queue limits instead. And couldn't we generically validate the constraints are not violated in submit_bio_noacct() instead of doing that in the low level driver? The driver assumes all other requests are already sanity checked, so I don't think we should change the responsibility for that just for this flag.