From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751797AbbCYXIZ (ORCPT ); Wed, 25 Mar 2015 19:08:25 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:32330 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750809AbbCYXIX (ORCPT ); Wed, 25 Mar 2015 19:08:23 -0400 Message-ID: <55133FD2.2040406@fb.com> Date: Wed, 25 Mar 2015 17:08:02 -0600 From: Jens Axboe User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Ming Lin-SSI , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" CC: "david@fromorbit.com" Subject: Re: [PATCH 4/7] Add stream ID support for buffered mpage/__block_write_full_page() References: <1427296070-8472-1-git-send-email-axboe@fb.com> <1427296070-8472-5-git-send-email-axboe@fb.com> <3A47B4705F6BE24CBB43C61AA7328621506980@SSIEXCH-MB3.ssi.samsung.com> In-Reply-To: <3A47B4705F6BE24CBB43C61AA7328621506980@SSIEXCH-MB3.ssi.samsung.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.54.13] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.13.68,1.0.33,0.0.0000 definitions=2015-03-25_07:2015-03-25,2015-03-25,1970-01-01 signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/25/2015 04:42 PM, Ming Lin-SSI wrote: >> -----Original Message----- >> From: Jens Axboe [mailto:axboe@fb.com] >> Sent: Wednesday, March 25, 2015 8:08 AM >> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org >> Cc: Ming Lin-SSI; david@fromorbit.com; Jens Axboe >> Subject: [PATCH 4/7] Add stream ID support for buffered >> mpage/__block_write_full_page() >> >> Pass on the inode stream ID to the bio allocation. >> >> Signed-off-by: Jens Axboe >> --- >> fs/buffer.c | 4 ++-- >> fs/mpage.c | 1 + >> 2 files changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/fs/buffer.c b/fs/buffer.c >> index 20805db2c987..0220925ff26d 100644 >> --- a/fs/buffer.c >> +++ b/fs/buffer.c >> @@ -1774,7 +1774,7 @@ static int __block_write_full_page(struct inode >> *inode, struct page *page, >> do { >> struct buffer_head *next = bh->b_this_page; >> if (buffer_async_write(bh)) { >> - submit_bh(write_op, bh); >> + _submit_bh(write_op, bh, >> streamid_to_flags(inode_streamid(inode))); >> nr_underway++; >> } >> bh = next; >> @@ -1828,7 +1828,7 @@ recover: >> struct buffer_head *next = bh->b_this_page; >> if (buffer_async_write(bh)) { >> clear_buffer_dirty(bh); >> - submit_bh(write_op, bh); >> + _submit_bh(write_op, bh, >> streamid_to_flags(inode_streamid(inode))); >> nr_underway++; >> } >> bh = next; >> diff --git a/fs/mpage.c b/fs/mpage.c >> index 3e79220babac..fba13f4b981d 100644 >> --- a/fs/mpage.c >> +++ b/fs/mpage.c >> @@ -605,6 +605,7 @@ alloc_new: >> bio_get_nr_vecs(bdev), >> GFP_NOFS|__GFP_HIGH); >> if (bio == NULL) >> goto confused; >> + bio_set_streamid(bio, inode_streamid(inode)); > > This will not work when multiple processes write to the same raw disk. > Let's say 2 process concurrently pwrite to /dev/nvme0n1 with different stream_id. > > Process 1: > fd = open("/dev/nvme0n1", ...); > posix_fadvise(fd, stream_id_1, 0, POSIX_FADV_STREAMID); > pwrite( fd, buf1, count1, offset1); > > Process 2: > fd = open("/dev/nvme0n1", ...); > posix_fadvise(fd, stream_id_2, 0, POSIX_FADV_STREAMID); > pwrite(fd, buf2, count2, offset2); > > One stream_id will overwrite the other one because "inode" is same. Well, that's how buffered writeback works... There's no file available at that point in time, in fact it could be long gone. So the only reliable part we have here is the inode. If you want the above scenario to work, you have to use O_DIRECT. Then it will work. -- Jens Axboe