linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] f2fs: flush dirty data for bmap
@ 2015-10-19 18:48 Jaegeuk Kim
  2015-10-19 18:48 ` [PATCH 2/2] f2fs: support fiemap for inline_data Jaegeuk Kim
  2015-10-20 15:09 ` [f2fs-dev] [PATCH 1/2] f2fs: flush dirty data for bmap Chao Yu
  0 siblings, 2 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2015-10-19 18:48 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

Users expect bmap will give allocated block addresses.
Let's play likewise ext4.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/data.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 77dfc9e..b052e7c 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1667,12 +1667,13 @@ static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
 {
 	struct inode *inode = mapping->host;
 
-	/* we don't need to use inline_data strictly */
-	if (f2fs_has_inline_data(inode)) {
-		int err = f2fs_convert_inline_inode(inode);
-		if (err)
-			return err;
-	}
+	if (f2fs_has_inline_data(inode))
+		return 0;
+
+	/* make sure allocating whole blocks */
+	if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY))
+		filemap_write_and_wait(mapping);
+
 	return generic_block_bmap(mapping, block, get_data_block_bmap);
 }
 
-- 
2.1.1


------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] f2fs: support fiemap for inline_data
  2015-10-19 18:48 [PATCH 1/2] f2fs: flush dirty data for bmap Jaegeuk Kim
@ 2015-10-19 18:48 ` Jaegeuk Kim
  2015-10-20 15:14   ` [f2fs-dev] " Chao Yu
  2015-10-20 15:09 ` [f2fs-dev] [PATCH 1/2] f2fs: flush dirty data for bmap Chao Yu
  1 sibling, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2015-10-19 18:48 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

There is a FIEMAP_EXTENT_INLINE_DATA, pointed out by Marc.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/data.c   |  6 ++++++
 fs/f2fs/f2fs.h   |  2 ++
 fs/f2fs/inline.c | 36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b052e7c..972eab7 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -771,6 +771,12 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 	if (ret)
 		return ret;
 
+	if (f2fs_has_inline_data(inode)) {
+		ret = f2fs_inline_data_fiemap(inode, fieinfo, start, len);
+		if (ret != -EAGAIN)
+			return ret;
+	}
+
 	mutex_lock(&inode->i_mutex);
 
 	if (len >= isize) {
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index c3443da..9db5500 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -2054,6 +2054,8 @@ void f2fs_delete_inline_entry(struct f2fs_dir_entry *, struct page *,
 bool f2fs_empty_inline_dir(struct inode *);
 int f2fs_read_inline_dir(struct file *, struct dir_context *,
 						struct f2fs_str *);
+int f2fs_inline_data_fiemap(struct inode *,
+		struct fiemap_extent_info *, __u64, __u64);
 
 /*
  * shrinker.c
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 3b18e23..bda7126 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -12,6 +12,7 @@
 #include <linux/f2fs_fs.h>
 
 #include "f2fs.h"
+#include "node.h"
 
 bool f2fs_may_inline_data(struct inode *inode)
 {
@@ -570,3 +571,38 @@ int f2fs_read_inline_dir(struct file *file, struct dir_context *ctx,
 	f2fs_put_page(ipage, 1);
 	return 0;
 }
+
+int f2fs_inline_data_fiemap(struct inode *inode,
+		struct fiemap_extent_info *fieinfo, __u64 start, __u64 len)
+{
+	__u64 byteaddr, ilen;
+	__u32 flags = FIEMAP_EXTENT_DATA_INLINE | FIEMAP_EXTENT_NOT_ALIGNED |
+		FIEMAP_EXTENT_LAST;
+	struct node_info ni;
+	struct page *ipage;
+	int err = 0;
+
+	ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
+	if (IS_ERR(ipage))
+		return PTR_ERR(ipage);
+
+	if (!f2fs_has_inline_data(inode)) {
+		err = -EAGAIN;
+		goto out;
+	}
+
+	ilen = min_t(size_t, MAX_INLINE_DATA, i_size_read(inode));
+	if (start >= ilen)
+		goto out;
+	if (start + len < ilen)
+		ilen = start + len;
+	ilen -= start;
+
+	get_node_info(F2FS_I_SB(inode), inode->i_ino, &ni);
+	byteaddr = (__u64)ni.blk_addr << inode->i_sb->s_blocksize_bits;
+	byteaddr += (char *)inline_data_addr(ipage) - (char *)F2FS_INODE(ipage);
+	err = fiemap_fill_next_extent(fieinfo, start, byteaddr, ilen, flags);
+out:
+	f2fs_put_page(ipage, 1);
+	return err;
+}
-- 
2.1.1


------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [f2fs-dev] [PATCH 1/2] f2fs: flush dirty data for bmap
  2015-10-19 18:48 [PATCH 1/2] f2fs: flush dirty data for bmap Jaegeuk Kim
  2015-10-19 18:48 ` [PATCH 2/2] f2fs: support fiemap for inline_data Jaegeuk Kim
@ 2015-10-20 15:09 ` Chao Yu
  1 sibling, 0 replies; 4+ messages in thread
From: Chao Yu @ 2015-10-20 15:09 UTC (permalink / raw)
  To: 'Jaegeuk Kim', linux-kernel, linux-fsdevel,
	linux-f2fs-devel

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Tuesday, October 20, 2015 2:49 AM
> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net; linux-kernel@vger.kernel.org;
> linux-fsdevel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net
> Cc: Jaegeuk Kim; Jaegeuk Kim
> Subject: [f2fs-dev] [PATCH 1/2] f2fs: flush dirty data for bmap
> 
> Users expect bmap will give allocated block addresses.
> Let's play likewise ext4.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <chao2.yu@samsung.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [f2fs-dev] [PATCH 2/2] f2fs: support fiemap for inline_data
  2015-10-19 18:48 ` [PATCH 2/2] f2fs: support fiemap for inline_data Jaegeuk Kim
@ 2015-10-20 15:14   ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2015-10-20 15:14 UTC (permalink / raw)
  To: 'Jaegeuk Kim', linux-kernel, linux-fsdevel,
	linux-f2fs-devel

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Tuesday, October 20, 2015 2:49 AM
> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net; linux-kernel@vger.kernel.org;
> linux-fsdevel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net
> Cc: Jaegeuk Kim; Jaegeuk Kim
> Subject: [f2fs-dev] [PATCH 2/2] f2fs: support fiemap for inline_data
> 
> There is a FIEMAP_EXTENT_INLINE_DATA, pointed out by Marc.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <chao2.yu@samsung.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-20 15:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-19 18:48 [PATCH 1/2] f2fs: flush dirty data for bmap Jaegeuk Kim
2015-10-19 18:48 ` [PATCH 2/2] f2fs: support fiemap for inline_data Jaegeuk Kim
2015-10-20 15:14   ` [f2fs-dev] " Chao Yu
2015-10-20 15:09 ` [f2fs-dev] [PATCH 1/2] f2fs: flush dirty data for bmap Chao Yu

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).