From patchwork Tue Apr 21 17:09:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lin X-Patchwork-Id: 6252181 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8CC4E9F313 for ; Tue, 21 Apr 2015 17:10:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A57D420295 for ; Tue, 21 Apr 2015 17:10:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 964B520274 for ; Tue, 21 Apr 2015 17:10:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755859AbbDURKR (ORCPT ); Tue, 21 Apr 2015 13:10:17 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:35713 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752394AbbDURKQ (ORCPT ); Tue, 21 Apr 2015 13:10:16 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NN6005W92D1ZA60@mailout3.samsung.com>; Wed, 22 Apr 2015 02:10:13 +0900 (KST) X-AuditID: cbfee61b-f79536d000000f1f-04-55368475f397 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id A7.50.03871.57486355; Wed, 22 Apr 2015 02:10:13 +0900 (KST) Received: from localhost.localdomain ([105.128.19.153]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NN6000782CXO430@mmp1.samsung.com>; Wed, 22 Apr 2015 02:10:13 +0900 (KST) From: Ming Lin To: linux-kernel@vger.kernel.org Cc: Jens Axboe , linux-fsdevel@vger.kernel.org, david@fromorbit.com, Changho Choi-SSI , "Kwan (Hingkwan) Huen-SSI" Subject: [RFC DRAFT PATCH] per-buffered-write stream IDs Date: Tue, 21 Apr 2015 10:09:47 -0700 Message-id: <1429636187-30236-1-git-send-email-ming.l@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAJMWRmVeSWpSXmKPExsVy+t9jAd3SFrNQg6+nDC3+7znGZrFq3X1G iy3H7jFaLJlxjs1iz96TLBaXd81hc2DzmNj8jt3j1CIJj7cvd7J6fN4kF8ASxWWTkpqTWZZa pG+XwJXx7eM09oKPShXH5qxnamB8JN3FyMkhIWAi8f3fETYIW0ziwr31QDYXh5DAIkaJgx1H oJyfjBInmlcwglSxCShLnD7/lh3EFhFQkNjc+4wVpIhZYDejxIIFx4AcDg5hAQuJ21csQEwW AVWJhqNuIOW8Ak4Sza++QS2Tkzh5bDLrBEbuBYwMqxhFUwuSC4qT0nON9IoTc4tL89L1kvNz NzGCw+GZ9A7GVQ0WhxgFOBiVeHhXTDANFWJNLCuuzD3EKMHBrCTCKyhkFirEm5JYWZValB9f VJqTWnyIUZqDRUmcd46uXKiQQHpiSWp2ampBahFMlomDU6qBcaFg2JFyjaMHT+zu3iyo+ClJ scZb5P/C7bbpR5+f6j9q8v9vVOV0xfclzs+kJtQtK9er3DiFveTbs2vKi7Wvt5mlBxyxK1V0 t+XgSolZ9ijffY2Ir+GfhdFaD22XHN1osHv5dA3hCSKPe6Y6seYuu8FXGlbzRiPuxZeHM78p dj5sc/7s+XXRdCWW4oxEQy3mouJEABqtqcsDAgAA Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Jens, This RFC DRAFT patch is on top of your "[PATCH v2] Support for write stream IDs" I throw it out early to get comments if it's the way to go. Quote LWN(http://lwn.net/Articles/638722): "There would be clear value in a closer association between stream IDs and specific buffered-write operations. Getting there would require storing the stream ID with each dirtied page, though; that, in turn, almost certainly implies shoehorning the stream ID into the associated page structure. That would not be an easy task; it is not surprising that it is not a part of this patch set. Should the lack of per-buffered-write stream IDs prove to be a serious constraint in the future, somebody will certainly be motivated to try to find a place to store another eight bits in struct page." This draft patch stores stream_id in buffer head instead of page. --- fs/buffer.c | 4 ++-- fs/ext4/page-io.c | 2 +- fs/mpage.c | 5 ++++- include/linux/buffer_head.h | 1 + mm/filemap.c | 17 +++++++++++++++++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 5191523..274fcc5 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, streamid_to_flags(inode_streamid(inode))); + _submit_bh(write_op, bh, streamid_to_flags(bh->b_streamid)); 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, streamid_to_flags(inode_streamid(inode))); + _submit_bh(write_op, bh, streamid_to_flags(bh->b_streamid)); nr_underway++; } bh = next; diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 980c5a9..c912129 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -406,7 +406,7 @@ submit_and_retry: ret = io_submit_init_bio(io, bh); if (ret) return ret; - bio_set_streamid(io->io_bio, inode_streamid(inode)); + bio_set_streamid(io->io_bio, bh->b_streamid); } ret = bio_add_page(io->io_bio, page, bh->b_size, bh_offset(bh)); if (ret != bh->b_size) diff --git a/fs/mpage.c b/fs/mpage.c index fba13f4..1c5ae1c 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -481,12 +481,15 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc, int length; struct buffer_head map_bh; loff_t i_size = i_size_read(inode); + int streamid = 0; int ret = 0; if (page_has_buffers(page)) { struct buffer_head *head = page_buffers(page); struct buffer_head *bh = head; + streamid = bh->b_streamid; + /* If they're all mapped and dirty, do it */ page_block = 0; do { @@ -605,7 +608,7 @@ alloc_new: bio_get_nr_vecs(bdev), GFP_NOFS|__GFP_HIGH); if (bio == NULL) goto confused; - bio_set_streamid(bio, inode_streamid(inode)); + bio_set_streamid(bio, streamid); } /* diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 73b4522..5dbb460 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -75,6 +75,7 @@ struct buffer_head { struct address_space *b_assoc_map; /* mapping this buffer is associated with */ atomic_t b_count; /* users using this buffer_head */ + unsigned int b_streamid; }; /* diff --git a/mm/filemap.c b/mm/filemap.c index 6bf5e42..3a31b95 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2419,6 +2419,21 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping, } EXPORT_SYMBOL(grab_cache_page_write_begin); +static void buffer_head_set_streamid(struct page *page, struct file *file) +{ + struct buffer_head *bh, *head; + + if (!page_has_buffers(page)) + return; + + head = page_buffers(page); + bh = head; + do { + bh->b_streamid = file->f_streamid; + bh = bh->b_this_page; + } while (bh != head); +} + ssize_t generic_perform_write(struct file *file, struct iov_iter *i, loff_t pos) { @@ -2466,6 +2481,8 @@ again: if (unlikely(status < 0)) break; + buffer_head_set_streamid(page, file); + if (mapping_writably_mapped(mapping)) flush_dcache_page(page);