]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
f2fs: don't reserve additional space in xattr block
authorChao Yu <yuchao0@huawei.com>
Thu, 23 Mar 2017 05:38:26 +0000 (13:38 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 24 Mar 2017 19:10:53 +0000 (15:10 -0400)
In this patch, we change xattr block disk layout as below:

Before:
xattr node block layout
+---------------------------------------------+---------------+-------------+
|           node block xattr entries          |   reserved    | node footer |
|                  4068 Bytes                 |    4 Bytes    |  24 Bytes   |

In memory layout
+--------------------+---------------------------------+--------------------+
|    inline xattr    |     node block xattr entries    |      reserved      |
|     200 Bytes      |         4068 Bytes              |      4 Bytes       |

After:
xattr node block layout
+-------------------------------------------------------------+-------------+
|                  node block xattr entries                   | node footer |
|                         4072 Bytes                          |  24 Bytes   |

In memory layout
+--------------------+---------------------------------+--------------------+
|    inline xattr    |     node block xattr entries    |      reserved      |
|     200 Bytes      |         4072 Bytes              |      4 Bytes       |

With this change, we don't need to reserve additional space in node block,
just keep reserved space in logical in-memory layout. So that it would help
to enlarge valid free space of xattr node block.

As tested, generic/026 shows max stored xattr entires number increases from
531 to 532 when inline_xattr option is enabled.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/xattr.c
fs/f2fs/xattr.h

index 528aed39981412d02e6cdff27ea8c9389fd73ebf..832c5110abab51208e77751056436e7ba7e7ff16 100644 (file)
@@ -256,7 +256,7 @@ static int lookup_all_xattrs(struct inode *inode, struct page *ipage,
        if (!size && !inline_size)
                return -ENODATA;
 
-       txattr_addr = kzalloc(inline_size + size + RESERVED_XATTR_SIZE,
+       txattr_addr = kzalloc(inline_size + size + XATTR_PADDING_SIZE,
                                                        GFP_F2FS_ZERO);
        if (!txattr_addr)
                return -ENOMEM;
@@ -332,7 +332,7 @@ static int read_all_xattrs(struct inode *inode, struct page *ipage,
        void *txattr_addr;
        int err;
 
-       txattr_addr = kzalloc(inline_size + size + RESERVED_XATTR_SIZE,
+       txattr_addr = kzalloc(inline_size + size + XATTR_PADDING_SIZE,
                                                        GFP_F2FS_ZERO);
        if (!txattr_addr)
                return -ENOMEM;
@@ -451,7 +451,7 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
        }
 
        xattr_addr = page_address(xpage);
-       memcpy(xattr_addr, txattr_addr + inline_size, MAX_XATTR_BLOCK_SIZE);
+       memcpy(xattr_addr, txattr_addr + inline_size, VALID_XATTR_BLOCK_SIZE);
        set_page_dirty(xpage);
        f2fs_put_page(xpage, 1);
 
index 1e7db8d0806e17b24f8979ac9a3a418b1fd15a41..6afcee35ebeba8f7dc821f8ca540d1b3345aeb94 100644 (file)
@@ -72,9 +72,8 @@ struct f2fs_xattr_entry {
                for (entry = XATTR_FIRST_ENTRY(addr);\
                                !IS_XATTR_LAST_ENTRY(entry);\
                                entry = XATTR_NEXT_ENTRY(entry))
-#define MAX_XATTR_BLOCK_SIZE   (PAGE_SIZE - sizeof(struct node_footer))
-#define RESERVED_XATTR_SIZE    (sizeof(__u32))
-#define VALID_XATTR_BLOCK_SIZE (MAX_XATTR_BLOCK_SIZE - RESERVED_XATTR_SIZE)
+#define VALID_XATTR_BLOCK_SIZE (PAGE_SIZE - sizeof(struct node_footer))
+#define XATTR_PADDING_SIZE     (sizeof(__u32))
 #define MIN_OFFSET(i)          XATTR_ALIGN(inline_xattr_size(i) +      \
                                                VALID_XATTR_BLOCK_SIZE)