From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C610C43381 for ; Thu, 28 Jan 2021 16:50:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FABA64E0D for ; Thu, 28 Jan 2021 16:50:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232693AbhA1Qt4 (ORCPT ); Thu, 28 Jan 2021 11:49:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232715AbhA1Qsf (ORCPT ); Thu, 28 Jan 2021 11:48:35 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90211C061756; Thu, 28 Jan 2021 08:47:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=ok1YlK16MaIquA7ZYUHxK/CMaFxxxwNWazaMAgFieLU=; b=vuOaMGbyB7/+Dg91fNUqvgBiBD 4apxS7jU5nU9b/DveQFuS18fYHTQPOpBZxMrv3tCqxWOuQg228bSNlkmvJ1gQneLnOfM3WL1ObNGi MTuz8xXL3LKzE+DH7errCMxepgPQ3Thh2HpLy2Nat9DQOLy35B1FC3UkIZuvmKmdZzwX86t+WV5Mk /pCa23DxPP5a3Rlkwfqrn59vty95NQBRWyuZpKNZRkjNLQlQ2KJrMub6IYLsf3IL2tz3nuZRbVWe7 TKvbqzYB3UBc6MLrjn2HVQGE6rKRMshHOwu50Myfj/erONbRzfW9chvly9np7Q4o+a4JR4iRTNdIG 5mKhGc+Q==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1l5ARp-008hlF-CH; Thu, 28 Jan 2021 16:47:23 +0000 Date: Thu, 28 Jan 2021 16:47:09 +0000 From: Matthew Wilcox To: Chaitanya Kulkarni Cc: Damien Le Moal , "linux-xfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "dm-devel@redhat.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "drbd-dev@lists.linbit.com" , "xen-devel@lists.xenproject.org" , "linux-nvme@lists.infradead.org" , "linux-scsi@vger.kernel.org" , "target-devel@vger.kernel.org" , "linux-fscrypt@vger.kernel.org" , "jfs-discussion@lists.sourceforge.net" , "linux-nilfs@vger.kernel.org" , "ocfs2-devel@oss.oracle.com" , "linux-pm@vger.kernel.org" , "linux-mm@kvack.org" , "shaggy@kernel.org" , "sergey.senozhatsky.work@gmail.com" , "snitzer@redhat.com" , "len.brown@intel.com" , "tiwai@suse.de" , "djwong@kernel.org" , "gustavoars@kernel.org" , "pavel@ucw.cz" , "alex.shi@linux.alibaba.com" , "agk@redhat.com" , "sagi@grimberg.me" , "osandov@fb.com" , "ebiggers@kernel.org" , "ngupta@vflare.org" , Naohiro Aota , "konrad.wilk@oracle.com" , "hare@suse.de" , "ming.lei@redhat.com" , "viro@zeniv.linux.org.uk" , "jefflexu@linux.alibaba.com" , "jaegeuk@kernel.org" , "konishi.ryusuke@gmail.com" , "bvanassche@acm.org" , "axboe@kernel.dk" , "jth@kernel.org" , "tytso@mit.edu" , "rjw@rjwysocki.net" , "philipp.reisner@linbit.com" , "minchan@kernel.org" , "tj@kernel.org" , "lars.ellenberg@linbit.com" , "roger.pau@citrix.com" , "asml.silence@gmail.com" Subject: Re: [Ocfs2-devel] [RFC PATCH 02/34] block: introduce and use bio_new Message-ID: <20210128164709.GZ308988@casper.infradead.org> References: <20210128071133.60335-1-chaitanya.kulkarni@wdc.com> <20210128071133.60335-3-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org FYI your email is completely unreadable to those not using html. I can't tell what you wrote and what Damien wrote. On Thu, Jan 28, 2021 at 08:33:10AM +0000, Chaitanya Kulkarni wrote: > On 1/27/21 11:21 PM, Damien Le Moal wrote: > > On 2021/01/28 16:12, Chaitanya Kulkarni wrote: > > > Introduce bio_new() helper and use it in blk-lib.c to allocate and > initialize various non-optional or semi-optional members of the bio > along with bio allocation done with bio_alloc(). Here we also calmp the > max_bvecs for bio with BIO_MAX_PAGES before we pass to bio_alloc(). > > Signed-off-by: Chaitanya Kulkarni > --- > block/blk-lib.c | 6 +----- > include/linux/bio.h | 25 +++++++++++++++++++++++++ > 2 files changed, 26 insertions(+), 5 deletions(-) > > diff --git a/block/blk-lib.c b/block/blk-lib.c > index fb486a0bdb58..ec29415f00dd 100644 > --- a/block/blk-lib.c > +++ b/block/blk-lib.c > @@ -14,17 +14,13 @@ struct bio *blk_next_bio(struct bio *bio, struct block_device *bdev, > sector_t sect, unsigned op, unsigned opf, > unsigned int nr_pages, gfp_t gfp) > { > - struct bio *new = bio_alloc(gfp, nr_pages); > + struct bio *new = bio_new(bdev, sect, op, opf, gfp, nr_pages); > > if (bio) { > bio_chain(bio, new); > submit_bio(bio); > } > > - new->bi_iter.bi_sector = sect; > - bio_set_dev(new, bdev); > - bio_set_op_attrs(new, op, opf); > - > return new; > } > > diff --git a/include/linux/bio.h b/include/linux/bio.h > index c74857cf1252..2a09ba100546 100644 > --- a/include/linux/bio.h > +++ b/include/linux/bio.h > @@ -826,5 +826,30 @@ static inline void bio_set_polled(struct bio *bio, struct kiocb *kiocb) > if (!is_sync_kiocb(kiocb)) > bio->bi_opf |= REQ_NOWAIT; > } > +/** > + * bio_new - allcate and initialize new bio > + * @bdev: blockdev to issue discard for > + * @sector: start sector > + * @op: REQ_OP_XXX from enum req_opf > + * @op_flags: REQ_XXX from enum req_flag_bits > + * @max_bvecs: maximum bvec to be allocated for this bio > + * @gfp_mask: memory allocation flags (for bio_alloc) > + * > + * Description: > + * Allocates, initializes common members, and returns a new bio. > + */ > +static inline struct bio *bio_new(struct block_device *bdev, sector_t sector, > + unsigned int op, unsigned int op_flags, > + unsigned int max_bvecs, gfp_t gfp_mask) > +{ > + unsigned nr_bvec = clamp_t(unsigned int, max_bvecs, 0, BIO_MAX_PAGES); > + struct bio *bio = bio_alloc(gfp_mask, nr_bvec); > > > I think that depending on the gfp_mask passed, bio can be NULL. So this should > be checked. > > > true, I'll add that check. > > > > > + > + bio_set_dev(bio, bdev); > + bio->bi_iter.bi_sector = sector; > + bio_set_op_attrs(bio, op, op_flags); > > > This function is obsolete. Open code this. > > > true, will do. > > > > > + > + return bio; > +} > > #endif /* __LINUX_BIO_H */ > > > > Thanks for the comments Damien. > _______________________________________________ > Ocfs2-devel mailing list > Ocfs2-devel@oss.oracle.com > https://oss.oracle.com/mailman/listinfo/ocfs2-devel