Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752745AbcDFBqn (ORCPT ); Tue, 5 Apr 2016 21:46:43 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:34286 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751186AbcDFBql (ORCPT ); Tue, 5 Apr 2016 21:46:41 -0400 Date: Tue, 5 Apr 2016 17:46:36 -0800 From: Kent Overstreet To: Ming Lei Cc: Jens Axboe , Linux Kernel Mailing List , linux-block@vger.kernel.org, Christoph Hellwig , Boaz Harrosh , Jan Kara , Keith Busch , Tejun Heo , Mike Snitzer Subject: Re: [PATCH 01/27] block: bio: introduce 4 helpers for cleanup Message-ID: <20160406014636.GB32713@kmo-pixel> References: <1459857443-20611-1-git-send-email-tom.leiming@gmail.com> <1459857443-20611-2-git-send-email-tom.leiming@gmail.com> <20160406001841.GA31161@kmo-pixel> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1863 Lines: 38 On Wed, Apr 06, 2016 at 09:34:34AM +0800, Ming Lei wrote: > On Wed, Apr 6, 2016 at 8:18 AM, Kent Overstreet > wrote: > > On Tue, Apr 05, 2016 at 07:56:46PM +0800, Ming Lei wrote: > >> Some drivers access bio->bi_vcnt and bio->bi_io_vec directly, > >> firstly it isn't a good practice, secondly it may cause trouble > >> for converting to multipage bvecs. > > > > "not good practice" is OO bullshit snake oil without more justification. We > > don't plaster accessors everywhere without an actual reason. > > > > How would it cause trouble with multipage bvecs? > > Simply speaking, the current drivers may depend on .bi_vcnt for > computing how many page there are in one bio. After multipage bvecs, > it is not true any more. Isn't it a actual reason? But it's completely valid to use bi_vcnt for segments, which is what it's always _really_ meant anyways. Sometimes you have cases where the meaning of a member changes significantly enough that you really don't want code using it accidentally anymore - like with Jens' patches that changed how bi_remaining and bi_cnt work, but after those patches it really wasn't correct to use those members directly anymore so he renamed them to prevent that. I don't buy that that's the case for multipage bvecs - the meaning of bi_vcnt itself isn't changing (it's just the number of entries in the array!) and it'll still be possible for code to correctly use it directly. Same with bio->bi_io_vec, it's still an array of biovecs, that's not changing. Your helpers are at the wrong level of abstraction. Also, there isn't a huge number of bi_vcnt references in the kernel anyways - the immutable biovec work required removing most of them. Instead of adding these low level accessors, it'd be better to convert code to higher level helpers (especially bio_add_page()) where applicable.