diff mbox

[1/1] iomap: Direct I/O for inline data

Message ID 20180627003906.15571-2-agruenba@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andreas Gruenbacher June 27, 2018, 12:39 a.m. UTC
Add support for reading from and writing to inline data to iomap_dio_rw.
This saves filesystems from having to implement fallback code for this
case.

The inline data is actually cached in the inode, so the I/O is only
direct in the sense that it doesn't go through the page cache.  The same
alignment restrictions as to non-inline data apply.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/iomap.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Comments

kernel test robot June 27, 2018, 1:44 a.m. UTC | #1
Hi Andreas,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.18-rc2 next-20180626]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Andreas-Gruenbacher/iomap-Direct-I-O-for-inline-data/20180627-084229
config: x86_64-randconfig-x015-201825 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:10:0,
                    from include/linux/list.h:9,
                    from include/linux/module.h:9,
                    from fs/iomap.c:14:
   fs/iomap.c: In function 'iomap_dio_actor_inline':
>> fs/iomap.c:971:56: error: 'struct iomap' has no member named 'inline_data'
     BUG_ON(pos + length > PAGE_SIZE - offset_in_page(iomap->inline_data));
                                                           ^
   include/linux/compiler.h:77:42: note: in definition of macro 'unlikely'
    # define unlikely(x) __builtin_expect(!!(x), 0)
                                             ^
>> fs/iomap.c:971:2: note: in expansion of macro 'BUG_ON'
     BUG_ON(pos + length > PAGE_SIZE - offset_in_page(iomap->inline_data));
     ^~~~~~
>> fs/iomap.c:971:36: note: in expansion of macro 'offset_in_page'
     BUG_ON(pos + length > PAGE_SIZE - offset_in_page(iomap->inline_data));
                                       ^~~~~~~~~~~~~~
   fs/iomap.c:977:16: error: 'struct iomap' has no member named 'inline_data'
       memset(iomap->inline_data + size, 0, pos - size);
                   ^~
   fs/iomap.c:978:32: error: 'struct iomap' has no member named 'inline_data'
      copied = copy_from_iter(iomap->inline_data + pos, length, iter);
                                   ^~
   fs/iomap.c:985:30: error: 'struct iomap' has no member named 'inline_data'
      copied = copy_to_iter(iomap->inline_data + pos, length, iter);
                                 ^~

vim +971 fs/iomap.c

   964	
   965	static loff_t iomap_dio_actor_inline(struct inode *inode, struct iomap_dio *dio,
   966			struct iomap *iomap, loff_t pos, loff_t length)
   967	{
   968		struct iov_iter *iter = dio->submit.iter;
   969		size_t copied;
   970	
 > 971		BUG_ON(pos + length > PAGE_SIZE - offset_in_page(iomap->inline_data));
   972	
   973		if (dio->flags & IOMAP_DIO_WRITE) {
   974			loff_t size = inode->i_size;
   975	
   976			if (pos > size)
   977				memset(iomap->inline_data + size, 0, pos - size);
   978			copied = copy_from_iter(iomap->inline_data + pos, length, iter);
   979			if (copied) {
   980				if (pos + copied > size)
   981					i_size_write(inode, pos + copied);
   982				mark_inode_dirty(inode);
   983			}
   984		} else {
   985			copied = copy_to_iter(iomap->inline_data + pos, length, iter);
   986		}
   987		dio->size += copied;
   988		return copied;
   989	}
   990	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/fs/iomap.c b/fs/iomap.c
index d393bb0c7384..74668b3ca2ed 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -1231,6 +1231,32 @@  iomap_dio_zero(struct iomap_dio *dio, struct iomap *iomap, loff_t pos,
 	return submit_bio(bio);
 }
 
+static loff_t iomap_dio_actor_inline(struct inode *inode, struct iomap_dio *dio,
+		struct iomap *iomap, loff_t pos, loff_t length)
+{
+	struct iov_iter *iter = dio->submit.iter;
+	size_t copied;
+
+	BUG_ON(pos + length > PAGE_SIZE - offset_in_page(iomap->inline_data));
+
+	if (dio->flags & IOMAP_DIO_WRITE) {
+		loff_t size = inode->i_size;
+
+		if (pos > size)
+			memset(iomap->inline_data + size, 0, pos - size);
+		copied = copy_from_iter(iomap->inline_data + pos, length, iter);
+		if (copied) {
+			if (pos + copied > size)
+				i_size_write(inode, pos + copied);
+			mark_inode_dirty(inode);
+		}
+	} else {
+		copied = copy_to_iter(iomap->inline_data + pos, length, iter);
+	}
+	dio->size += copied;
+	return copied;
+}
+
 static loff_t
 iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
 		void *data, struct iomap *iomap)
@@ -1281,6 +1307,8 @@  iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
 				use_fua = true;
 		}
 		break;
+	case IOMAP_INLINE:
+		return iomap_dio_actor_inline(inode, dio, iomap, pos, length);
 	default:
 		WARN_ON_ONCE(1);
 		return -EIO;