All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org,
	adilger@dilger.ca, hch@infradead.org, martin.petersen@oracle.com
Subject: Re: [PATCH 04/11] fs: add support for allowing applications to pass in write life time hints
Date: Wed, 14 Jun 2017 22:33:16 -0600	[thread overview]
Message-ID: <a0689580-ac50-3e2c-7c00-2d59e130c9a9@kernel.dk> (raw)
In-Reply-To: <20170615041503.GB4521@birch.djwong.org>

On 06/14/2017 10:15 PM, Darrick J. Wong wrote:
>> diff --git a/fs/read_write.c b/fs/read_write.c
>> index 47c1d4484df9..9cb2314efca3 100644
>> --- a/fs/read_write.c
>> +++ b/fs/read_write.c
>> @@ -678,7 +678,7 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
>>  	struct kiocb kiocb;
>>  	ssize_t ret;
>>  
>> -	if (flags & ~(RWF_HIPRI | RWF_DSYNC | RWF_SYNC))
>> +	if (flags & ~(RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_WRITE_LIFE_MASK))
>>  		return -EOPNOTSUPP;
>>  
>>  	init_sync_kiocb(&kiocb, filp);
>> @@ -688,6 +688,13 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
>>  		kiocb.ki_flags |= IOCB_DSYNC;
>>  	if (flags & RWF_SYNC)
>>  		kiocb.ki_flags |= (IOCB_DSYNC | IOCB_SYNC);
>> +	if (flags & RWF_WRITE_LIFE_MASK) {
>> +		struct inode *inode = file_inode(filp);
>> +
>> +		inode->i_write_hint = (flags & RWF_WRITE_LIFE_MASK) >>
>> +					RWF_WRITE_LIFE_SHIFT;
> 
> Hmm, so once set, hints stick around until someone else sets a different
> one.  I suppose it's unlikely that you'd have two programs writing to
> the same inode with different write hints, right?

You'd hope so... There's really no good way to support that with
buffered writes. For the NVMe use case, you'd be no worse off than you
were without hints, however.

But I do think one change should be made above - we only reset the hint
if someone passes a new hint in. But we probably also want to do so for
the case where no hint is passed in, but one is currently set.

> Also, how does userspace query the write hint value once set?

It doesn't. Ideally this hint would be "for this write only", but that's
not really possible with deferred write back.

>> +/*
>> + * Data life time write flags, steal 4 bits for that
>> + */
>> +#define RWF_WRITE_LIFE_SHIFT		4
>> +#define RWF_WRITE_LIFE_MASK		0x000000f0 /* 4 bits of stream ID */
>> +#define RWF_WRITE_LIFE_SHORT		(1 << RWF_WRITE_LIFE_SHIFT)
>> +#define RWF_WRITE_LIFE_MEDIUM		(2 << RWF_WRITE_LIFE_SHIFT)
>> +#define RWF_WRITE_LIFE_LONG		(3 << RWF_WRITE_LIFE_SHIFT)
>> +#define RWF_WRITE_LIFE_EXTREME		(4 << RWF_WRITE_LIFE_SHIFT)
> 
> Should O_TMPFILE files ought to be created with i_write_hint =
> RWF_WRITE_LIFE_SHORT by default?

The answer here is "it depends". If we're already using hints on that
device, then yes, O_TMPFILE is a clear candidate for
RWF_WRITE_LIFE_SHORT. However, if we are not, then we should not set it
as it may have implications on how the device manages writes. For that
case we'll potentially only be driving a single stream, short writes,
and that may not be enough to saturate device bandwidth.

I would rather leave that for future experimentation. There are similar
things we can do with short lived writes, like apply them to the log
writes in the file system. But all of that should be built on top of
what we end up agreeing on, not included from the get-go. I'd rather get
the basic usage and model going first before we further complicate
matters.

-- 
Jens Axboe

  reply	other threads:[~2017-06-15  4:33 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15  3:45 [PATCHSET v4] Add support for write life time hints Jens Axboe
2017-06-15  3:45 ` [PATCH 01/11] block: add support for carrying stream information in a bio Jens Axboe
2017-06-15  3:45 ` [PATCH 02/11] blk-mq: expose stream write stats through debugfs Jens Axboe
2017-06-15  8:16   ` Christoph Hellwig
2017-06-15 14:24     ` Jens Axboe
2017-06-15  3:45 ` [PATCH 03/11] fs: add support for an inode to carry stream related data Jens Axboe
2017-06-15  8:17   ` Christoph Hellwig
2017-06-15 14:22     ` Jens Axboe
2017-06-15  3:45 ` [PATCH 04/11] fs: add support for allowing applications to pass in write life time hints Jens Axboe
2017-06-15  4:15   ` Darrick J. Wong
2017-06-15  4:33     ` Jens Axboe [this message]
2017-06-15  8:19       ` Christoph Hellwig
2017-06-15 14:21         ` Jens Axboe
2017-06-15 15:23           ` Jens Axboe
2017-06-16  7:30             ` Christoph Hellwig
2017-06-16 14:35               ` Jens Axboe
2017-06-16  7:33           ` Christoph Hellwig
2017-06-16 14:35             ` Jens Axboe
2017-06-16 14:53               ` Jens Axboe
2017-06-16 15:52               ` Christoph Hellwig
2017-06-16 15:59                 ` Jens Axboe
2017-06-16 16:14                   ` Jens Axboe
2017-06-16 18:00                     ` Christoph Hellwig
2017-06-16 18:02                   ` Christoph Hellwig
2017-06-16 19:35                     ` Jens Axboe
2017-06-15 11:24     ` Al Viro
2017-06-15  3:45 ` [PATCH 05/11] block: add helpers for setting/checking write hint validity Jens Axboe
2017-06-15  3:45 ` [PATCH 06/11] fs: add O_DIRECT support for sending down bio stream information Jens Axboe
2017-06-15  3:45 ` [PATCH 07/11] fs: add support for buffered writeback to pass down write hints Jens Axboe
2017-06-15  3:45 ` [PATCH 08/11] ext4: add support for passing in write hints for buffered writes Jens Axboe
2017-06-15  3:45 ` [PATCH 09/11] xfs: " Jens Axboe
2017-06-15  3:45 ` [PATCH 10/11] btrfs: " Jens Axboe
2017-06-15  3:45 ` [PATCH 11/11] nvme: add support for streams and directives Jens Axboe
2017-06-15  8:12 ` [PATCHSET v4] Add support for write life time hints Christoph Hellwig
2017-06-15 14:23   ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2017-06-17 19:59 [PATCHSET v7] " Jens Axboe
2017-06-17 19:59 ` [PATCH 04/11] fs: add support for allowing applications to pass in " Jens Axboe
2017-06-19  6:27   ` Christoph Hellwig
2017-06-19 14:56     ` Jens Axboe
2017-06-19 16:02       ` Jens Axboe
2017-06-19 18:58         ` Christoph Hellwig
2017-06-19 19:00           ` Jens Axboe
2017-06-19 19:10             ` Jens Axboe
2017-06-19 20:33               ` Jens Axboe
2017-06-20  2:06                 ` Jens Axboe
2017-06-20  8:57                 ` Christoph Hellwig
2017-06-20 12:43                   ` Jens Axboe
2017-06-20 12:43                     ` Christoph Hellwig
2017-06-20 12:45                       ` Jens Axboe
2017-06-20 12:47                         ` Christoph Hellwig
2017-06-20 12:51                           ` Jens Axboe
2017-06-20 12:56                             ` Christoph Hellwig
2017-06-20 13:00                               ` Jens Axboe
2017-06-16 17:24 [PATCHSET v6] Add support for " Jens Axboe
2017-06-16 17:24 ` [PATCH 04/11] fs: add support for allowing applications to pass in " Jens Axboe
2017-06-14 19:05 [PATCHSET v3] Add support for " Jens Axboe
2017-06-14 19:05 ` [PATCH 04/11] fs: add support for allowing applications to pass in " Jens Axboe
2017-06-14 20:26   ` Christoph Hellwig
2017-06-14 20:37     ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a0689580-ac50-3e2c-7c00-2d59e130c9a9@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=adilger@dilger.ca \
    --cc=darrick.wong@oracle.com \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.