Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1431826lqj; Tue, 4 Jun 2024 00:55:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXkDaGX1KsD5zOJu9Pnjn1zD4hIVB5bNhKX/Y6+KO9bK425ezQ1RR5O0HJ4w/3JbXvTTt5HIKJPgbL2ewyZn2mWMUjwaaO/bQWSuqPEwA== X-Google-Smtp-Source: AGHT+IHWA1lEk4xH6+XDZ0JnRVqgU6G2VhFyRRrzHdQOUef+8GwVNbytpzI7bBlJad+M9g27D4NA X-Received: by 2002:a05:6808:486:b0:3d1:ff25:6492 with SMTP id 5614622812f47-3d1ff2564ffmr682099b6e.6.1717487748785; Tue, 04 Jun 2024 00:55:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717487748; cv=pass; d=google.com; s=arc-20160816; b=qiOg2BYBDCuvmyJAUS/gh/KyrULt9F1CDBm4r7dJFHiRIC/rHojD/GNYM4k1ubCoG+ mV5dHG01Gmhwg5k/j0N5gFivNd4bDBOmgkrwt/7RUAboPjF9WCpTwZmwcSxJHfK52kto CEf/EWFJEoLK9uvag4uPnBqrVtdpMIHBoWHecAc+v9G3NLM4rB00wpBmg12z27MQIazm BwYdji5lWvj3XdRkbVU5P/DcRFOm6ME66oGQ48v3kUdk613lmTSpqdFMQR+qjuob7Mf0 NLXffpVY2sTdR6xv1o2sHtmmVZPA9BL3eqDhWaGQe8gl+8794JfqCuVZgE5wIoTgJxaQ wGGA== 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=ytAhbThPNjXTfUodETZzpPMZu1FR/UjRFuF7PD2TYzI=; fh=NxxAv7q2Qki4szZcL1FsGfsT5hlZGWG19xV87SepgGQ=; b=t154O1+Nrw5gUWIqG9/tmUXOs1Re0kZvmCCG5kqYaovPGkhCGwuOgHb+jiuCFtnAwk 1M12ebU12Ou10S8MaUThN+ugalJBF/WYwcZyM/j5XZnto36er4svDGGPwxIqXQnxNESa R3IUfZFBl/GmtWiZQMoclqupmx6q2hUr+Ud08Q5GS0NxJVky2xsp8fPAUbWysLUYzwRS Kj/R38q8nW/67dRaqj/eMDqA45lHlc7A1Fjd6T6sOvRMLaA0wIONm3F3kO+8tlhLivuW S6UgTamQzXUE179m9FwdXAnEjahwOqogk7wAviY3H03wYPnYkUNnrz7zM/Rftg1CztfV LyUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=l2GdXoju; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-200025-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200025-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d2e1a72fcca58-70260d9c2e6si1555239b3a.97.2024.06.04.00.55.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 00:55:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200025-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=l2GdXoju; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-200025-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200025-linux.lists.archive=gmail.com@vger.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AD08DB2099C for ; Tue, 4 Jun 2024 04:46:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70CC113D88D; Tue, 4 Jun 2024 04:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="l2GdXoju" Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 51AEF17741; Tue, 4 Jun 2024 04:46:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717476386; cv=none; b=uUVp4FQLNIyzwHjKjX6BRbU6CPND6yShEVPwWBU+9BC78vsZ4wPI8LVRG9izNdITF6Zoh42g9QpUni0WB2yMtDme2voiY++aV5lml1Eqj3g97hHr00fFSNlBrFfEzt9nNX30zpI9c3k2gmAFFd3gCB/InD1W6m8IIuzLPeIdHTM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717476386; c=relaxed/simple; bh=lF+3ndP0Ib1DsiimtVj/EelNOErTHudK0jOBHFzWKcw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HqwhkNbmyGiCcGsvVQQde+S0ShYxEKcgFo0DPQeazCsRnO+FZ8MDfwcSU0cJFgT6zJoIWbfKcOQrr6JO3MjcEPONYsIMFObUYklpDH5ob/O0vHFBiBSJQx2TG62vOU07wDMlu8A5JBgdzkII0UwKV9W2U2usgvsZgOpXxx+2jZs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=l2GdXoju; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ytAhbThPNjXTfUodETZzpPMZu1FR/UjRFuF7PD2TYzI=; b=l2GdXojuHsJXgJ4rpXKIfG1a0T s7k0GA6kXT4jmAJ4e0Ji7+4860jftg8sUu+AXLp8nzI++WuKr1gNaxLjPSoYudHkKFHheYsHGC9ic bfbqBQIYxPUg7DXSrg1+c1Vmo9/UPjMZt9P8SbdxRNoiC4JzzeFhy4B64YZAimVs9cYeozmZqb3dE 1npH6HwmFfaIJXkk8Fl31/PP0I6EqXzHHRy9/u+sZvwjmrInqX6VSlXKRoW73Mtk7SNkXtrXQZMK9 rRO7LuuSfij1iEx9iK8a/xLDCzO5OMksMrSCd+wuQ4mqf6kztx6PqvwSueR3zhUyaBkLIW1cHAm4l ZzMQiSVw==; Received: from hch by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEM3w-00000001CWj-48dY; Tue, 04 Jun 2024 04:46:20 +0000 Date: Mon, 3 Jun 2024 21:46:20 -0700 From: Christoph Hellwig To: Keith Busch Cc: Andreas Hindborg , Jens Axboe , Andreas Hindborg , Bart Van Assche , John Garry , Damien Le Moal , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] null_blk: fix validation of block size Message-ID: References: <20240603192645.977968-1-nmi@metaspace.dk> 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: X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html On Mon, Jun 03, 2024 at 01:47:17PM -0600, Keith Busch wrote: > On Mon, Jun 03, 2024 at 09:26:45PM +0200, Andreas Hindborg wrote: > > - dev->blocksize = round_down(dev->blocksize, 512); > > - dev->blocksize = clamp_t(unsigned int, dev->blocksize, 512, 4096); > > + if (blk_validate_block_size(dev->blocksize) != 0) { > > + return -EINVAL; > > + } > > No need for the { } brackets for a one-line if. or the != 0. > > It also looks like a good idea if this check was just done in > blk_validate_limits() so that each driver doesn't have to do their own > checks. That block function is kind of recent though. Yes. We already discussed this in another thread a few days ago.