Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751514AbbDLKmY (ORCPT ); Sun, 12 Apr 2015 06:42:24 -0400 Received: from mail-lb0-f182.google.com ([209.85.217.182]:36341 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751332AbbDLKmU (ORCPT ); Sun, 12 Apr 2015 06:42:20 -0400 From: Dmitry Monakhov To: Dave Chinner , 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 In-Reply-To: <20150325023014.GC31342@dastard> References: <1427210823-5283-1-git-send-email-axboe@fb.com> <1427210823-5283-2-git-send-email-axboe@fb.com> <20150325023014.GC31342@dastard> User-Agent: Notmuch/0.18.1 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-redhat-linux-gnu) Date: Sun, 12 Apr 2015 14:42:16 +0400 Message-ID: <876191fx13.fsf@openvz.org> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2135 Lines: 62 Dave Chinner writes: > 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. Definitely. User may set it only if it has CAP_RESOURCES. This is fun, but we act as a soviet nomenclature who try to monopolize food distribution system :) > > Cheers, > > Dave. > -- > Dave Chinner > david@fromorbit.com > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/