From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752858AbbCYCaS (ORCPT ); Tue, 24 Mar 2015 22:30:18 -0400 Received: from ipmail06.adl2.internode.on.net ([150.101.137.129]:62186 "EHLO ipmail06.adl2.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752756AbbCYCaQ (ORCPT ); Tue, 24 Mar 2015 22:30:16 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BRCAAMHRJVPAYQLHlcgwaBLIY/rGUBAQEBAQEGmQwEAgKBTk0BAQEBAQEGAQEBATg7hBUBBScTHCMQCAMYCSUPBSUDBxoTiC7JagEBAQcCAR8YhXWFFIR2B4MXgRYBBJo+lC2CJByBZCoxgkMBAQE Date: Wed, 25 Mar 2015 13:30:14 +1100 From: Dave Chinner To: Jens Axboe Cc: axboe@kernel.dk, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, ming.l@ssi.samsung.com Subject: Re: [PATCH 1/6] block: add support for carrying a stream ID in a bio Message-ID: <20150325023014.GC31342@dastard> References: <1427210823-5283-1-git-send-email-axboe@fb.com> <1427210823-5283-2-git-send-email-axboe@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1427210823-5283-2-git-send-email-axboe@fb.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 24, 2015 at 09:26:58AM -0600, Jens Axboe wrote: > The top bits of bio->bi_flags are reserved for keeping the > allocation pool, set aside the next four bits for carrying > a stream ID. That leaves us with support for 15 streams, > 0 is reserved as a "stream not set" value. > > Add helpers for setting/getting stream ID of a bio. .... > +/* > + * after the pool bits, next 4 bits are for the stream id > + */ > +#define BIO_STREAM_BITS (4) > +#define BIO_STREAM_OFFSET (BITS_PER_LONG - 8) > +#define BIO_STREAM_MASK ((1 << BIO_STREAM_BITS) - 1) > + > +static inline unsigned long streamid_to_flags(unsigned int id) > +{ > + return (unsigned long) (id & BIO_STREAM_MASK) << BIO_STREAM_OFFSET; > +} > + > +static inline void bio_set_streamid(struct bio *bio, unsigned int id) > +{ > + bio->bi_flags |= streamid_to_flags(id); > +} > + > +static inline unsigned int bio_get_streamid(struct bio *bio) > +{ > + return (bio->bi_flags >> BIO_STREAM_OFFSET) & BIO_STREAM_MASK; > +} > + > +static inline bool bio_streamid_valid(struct bio *bio) > +{ > + return bio_get_streamid(bio) != 0; > +} Need to reserve at least one stream for filesystem private use (e.g. metadata writeback). Potentially 2 streams - one for the journal which is frequently overwritten, the other for all other long lived persistent metadata. Cheers, Dave. -- Dave Chinner david@fromorbit.com