From: Goldwyn Rodrigues <rgoldwyn@suse.de>
To: linux-btrfs@vger.kernel.org
Cc: Goldwyn Rodrigues <rgoldwyn@suse.com>
Subject: [RFC PATCH 3/8] fs: Introduce IOMAP_F_NOBH
Date: Fri, 17 Nov 2017 11:44:49 -0600 [thread overview]
Message-ID: <20171117174456.13393-4-rgoldwyn@suse.de> (raw)
In-Reply-To: <20171117174456.13393-1-rgoldwyn@suse.de>
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
IOMAP_F_NOBH tells iomap functions not to use or attach buffer heads
to the page. Page flush and writeback is the responsibility of the
filesystem (such as btrfs) code, which use bio to perform it.
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
fs/iomap.c | 20 ++++++++++++--------
include/linux/iomap.h | 1 +
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/fs/iomap.c b/fs/iomap.c
index d4801f8dd4fd..9ec9cc3077b3 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -123,7 +123,8 @@ iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
if (!page)
return -ENOMEM;
- status = __block_write_begin_int(page, pos, len, NULL, iomap);
+ if (!(iomap->flags & IOMAP_F_NOBH))
+ status = __block_write_begin_int(page, pos, len, NULL, iomap);
if (unlikely(status)) {
unlock_page(page);
put_page(page);
@@ -138,12 +139,15 @@ iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
static int
iomap_write_end(struct inode *inode, loff_t pos, unsigned len,
- unsigned copied, struct page *page)
+ unsigned copied, struct page *page, struct iomap *iomap)
{
- int ret;
+ int ret = len;
- ret = generic_write_end(NULL, inode->i_mapping, pos, len,
- copied, page, NULL);
+ if (iomap->flags & IOMAP_F_NOBH)
+ ret = inode_extend_page(inode, pos, copied, page);
+ else
+ ret = generic_write_end(NULL, inode->i_mapping, pos, len,
+ copied, page, NULL);
if (ret < len)
iomap_write_failed(inode, pos, len);
return ret;
@@ -198,7 +202,7 @@ iomap_write_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
flush_dcache_page(page);
- status = iomap_write_end(inode, pos, bytes, copied, page);
+ status = iomap_write_end(inode, pos, bytes, copied, page, iomap);
if (unlikely(status < 0))
break;
copied = status;
@@ -292,7 +296,7 @@ iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
WARN_ON_ONCE(!PageUptodate(page));
- status = iomap_write_end(inode, pos, bytes, bytes, page);
+ status = iomap_write_end(inode, pos, bytes, bytes, page, iomap);
if (unlikely(status <= 0)) {
if (WARN_ON_ONCE(status == 0))
return -EIO;
@@ -344,7 +348,7 @@ static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset,
zero_user(page, offset, bytes);
mark_page_accessed(page);
- return iomap_write_end(inode, pos, bytes, bytes, page);
+ return iomap_write_end(inode, pos, bytes, bytes, page, iomap);
}
static int iomap_dax_zero(loff_t pos, unsigned offset, unsigned bytes,
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 8a7c6d26b147..61af7b1bd0fc 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -29,6 +29,7 @@ struct vm_fault;
*/
#define IOMAP_F_MERGED 0x10 /* contains multiple blocks/extents */
#define IOMAP_F_SHARED 0x20 /* block shared with another file */
+#define IOMAP_F_NOBH 0x40 /* Do not assign buffer heads */
/*
* Magic value for blkno:
--
2.14.2
next prev parent reply other threads:[~2017-11-17 17:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 17:44 [RFC PATCH 0/8] btrfs iomap support Goldwyn Rodrigues
2017-11-17 17:44 ` [RFC PATCH 1/8] btrfs: use iocb for __btrfs_buffered_write Goldwyn Rodrigues
2018-04-10 16:19 ` David Sterba
2018-05-22 6:40 ` Misono Tomohiro
2018-05-22 10:03 ` David Sterba
2017-11-17 17:44 ` [RFC PATCH 2/8] fs: Add inode_extend_page() Goldwyn Rodrigues
2017-11-17 17:44 ` Goldwyn Rodrigues [this message]
2017-11-17 17:44 ` [RFC PATCH 4/8] btrfs: Introduce btrfs_iomap Goldwyn Rodrigues
2017-11-17 17:44 ` [RFC PATCH 5/8] btrfs: use iomap to perform buffered writes Goldwyn Rodrigues
2017-11-17 17:44 ` [RFC PATCH 6/8] btrfs: read the first/last page of the write Goldwyn Rodrigues
2017-11-17 17:44 ` [RFC PATCH 7/8] fs: iomap->prepare_pages() to set directives specific for the page Goldwyn Rodrigues
2017-11-17 17:44 ` Goldwyn Rodrigues
2017-11-17 17:44 ` [RFC PATCH 8/8] fs: Introduce iomap->dirty_page() Goldwyn Rodrigues
2017-11-17 17:44 ` [RFC PATCH 8/8] iomap: " Goldwyn Rodrigues
2017-11-17 18:45 ` [RFC PATCH 0/8] btrfs iomap support Nikolay Borisov
2017-11-17 23:07 ` Goldwyn Rodrigues
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=20171117174456.13393-4-rgoldwyn@suse.de \
--to=rgoldwyn@suse.de \
--cc=linux-btrfs@vger.kernel.org \
--cc=rgoldwyn@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).