Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28838129rwd; Wed, 5 Jul 2023 03:34:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlGzZLPeU6REG7+tpav249SINwMSM0pN35ZJhtFNyls0Z3iWmbNcvKRVkUC6ULoh5cR9k2mi X-Received: by 2002:a17:90a:8cf:b0:262:f0e6:9e09 with SMTP id 15-20020a17090a08cf00b00262f0e69e09mr14896362pjn.14.1688553257875; Wed, 05 Jul 2023 03:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688553257; cv=none; d=google.com; s=arc-20160816; b=V71yETd3LT/G3/+0IgV0VYzuVd0PnkQW+Wa6bQ2w2yki89JH08xgt8CbpOkeGCjTgR QMF8WaeGHnMyhdBbmUjM+RTgjUL5bxkpMqv6BPMFy4/u1ZbLIU9XkXQw6SIqI2B7mDhh CRZmz5Eh/09PPZG+HqdoC/gOvC8RZFl4tmzmnLAz+GbUZNJVamyrtxfFYd9fa++nyMcm 0jA6V/0y0IOX6GRDpVa7AucC7p4L78l0hLGwpYgbpc7+OpX/7n5Bnep6QnAxkUDGISsL SYFRMJd6Ie247/uh3Uv6Rjzu7caGbgRW+9JfR5cHk6GS4QhLKewToMlWt4ccD2o+bwXV jVIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=qqER76PXnxWxMVZH46uY+IP0A7ISNxa4dFOpqm8Npig=; fh=L0qlWEkswmxfm3z2xDjRZa1YEINcH3c8LbqHQ7adfhg=; b=JzFUqe1lwoM2kbk9FjccdqMx4pdut5QOORtYXV113N8NRUqowE5/XWd6d43wfal8iU sDfpbdPWXXWQdGU6hTtpM+O3zyeZFAzWAp0XbHjE2cLegHfIhm6oJlNT4loky0tErI0N BZv8XXxyPZPoYszKHYs28SgrXQnEK6jAyjaRgObH1MLBk6tNMHrekB6zZckQHvrG3+Yo Ns3oGFukds9aOqD1cAfzKe6VUwMaSVwdgCn8HiQQNNtbqvVNJ0uZ8g3CHCGgiN81/6NL 1OYoQ4jXH58FBlyDg2xCMLCjSpZxFgBTauUYRGe+f+fguzo8KEsV3fKeJnKwPjJClbGG lpvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=rK+eFTza; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a15-20020a17090a8c0f00b00262f99a851asi1318969pjo.96.2023.07.05.03.34.00; Wed, 05 Jul 2023 03:34:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=rK+eFTza; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231593AbjGEKVc (ORCPT + 99 others); Wed, 5 Jul 2023 06:21:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbjGEKVb (ORCPT ); Wed, 5 Jul 2023 06:21:31 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A246B122; Wed, 5 Jul 2023 03:21:30 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 58F0C1F6E6; Wed, 5 Jul 2023 10:21:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1688552489; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qqER76PXnxWxMVZH46uY+IP0A7ISNxa4dFOpqm8Npig=; b=rK+eFTza2+XXgbRvOv5tQtV93F/4zZpu7norREAepZy5yow7baD/dvvqWhpeeItBt0IPcu Y5rwLWutv/on4mwv5EJraqTeqhb05mRkTW0yYXikGz/UA9AQcATVDIgxrBuvXRHMAszN6R RSIAN/j2D8s9RJrt3/Umhb+lT3pvazU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1688552489; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qqER76PXnxWxMVZH46uY+IP0A7ISNxa4dFOpqm8Npig=; b=0Ik5A3faiNr6MKUo0ZlFf0SVDy0zGGeX4x6PTOEnPlUJVjHk96v3tsbq/TGqKcufwhGJGx 3sf2EXg0rHzUTICQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 44C0D13460; Wed, 5 Jul 2023 10:21:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Xem5EClEpWRSCwAAMHmgww (envelope-from ); Wed, 05 Jul 2023 10:21:29 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id C5467A0707; Wed, 5 Jul 2023 12:21:28 +0200 (CEST) Date: Wed, 5 Jul 2023 12:21:28 +0200 From: Jan Kara To: Keith Busch Cc: Jan Kara , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jens Axboe , Christoph Hellwig , Alasdair Kergon , Andrew Morton , Anna Schumaker , Chao Yu , Christian Borntraeger , "Darrick J. Wong" , Dave Kleikamp , David Sterba , dm-devel@redhat.com, drbd-dev@lists.linbit.com, Gao Xiang , Jack Wang , Jaegeuk Kim , jfs-discussion@lists.sourceforge.net, Joern Engel , Joseph Qi , Kent Overstreet , linux-bcache@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mm@kvack.org, linux-mtd@lists.infradead.org, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-nvme@lists.infradead.org, linux-pm@vger.kernel.org, linux-raid@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-xfs@vger.kernel.org, "Md. Haris Iqbal" , Mike Snitzer , Minchan Kim , ocfs2-devel@oss.oracle.com, reiserfs-devel@vger.kernel.org, Sergey Senozhatsky , Song Liu , Sven Schnelle , target-devel@vger.kernel.org, Ted Tso , Trond Myklebust , xen-devel@lists.xenproject.org Subject: Re: [PATCH 01/32] block: Provide blkdev_get_handle_* functions Message-ID: <20230705102128.vquve4qencbbn2br@quack3> References: <20230629165206.383-1-jack@suse.cz> <20230704122224.16257-1-jack@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue 04-07-23 10:28:36, Keith Busch wrote: > On Tue, Jul 04, 2023 at 02:21:28PM +0200, Jan Kara wrote: > > +struct bdev_handle *blkdev_get_handle_by_dev(dev_t dev, blk_mode_t mode, > > + void *holder, const struct blk_holder_ops *hops) > > +{ > > + struct bdev_handle *handle = kmalloc(sizeof(struct bdev_handle), > > + GFP_KERNEL); > > I believe 'sizeof(*handle)' is the preferred style. OK. > > + struct block_device *bdev; > > + > > + if (!handle) > > + return ERR_PTR(-ENOMEM); > > + bdev = blkdev_get_by_dev(dev, mode, holder, hops); > > + if (IS_ERR(bdev)) > > + return ERR_CAST(bdev); > > Need a 'kfree(handle)' before the error return. Or would it be simpler > to get the bdev first so you can check the mode settings against a > read-only bdev prior to the kmalloc? Yeah. Good point with kfree(). I'm not sure calling blkdev_get_by_dev() first will be "simpler" - then we need blkdev_put() in case of kmalloc() failure. Thanks for review! Honza -- Jan Kara SUSE Labs, CR