linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz
Subject: [PATCH v3 2/6] btrfs-progs: mkfs/rootdir: Fix inline extent creation check
Date: Tue, 20 Mar 2018 14:42:25 +0800	[thread overview]
Message-ID: <20180320064229.31493-3-wqu@suse.com> (raw)
In-Reply-To: <20180320064229.31493-1-wqu@suse.com>

Just like convert, we need extra check against sector size for creating
inline extent.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 mkfs/rootdir.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mkfs/rootdir.c b/mkfs/rootdir.c
index e06b65ac13e4..a1d223a2408a 100644
--- a/mkfs/rootdir.c
+++ b/mkfs/rootdir.c
@@ -139,7 +139,8 @@ static int fill_inode_item(struct btrfs_trans_handle *trans,
 	}
 	if (S_ISREG(src->st_mode)) {
 		btrfs_set_stack_inode_size(dst, (u64)src->st_size);
-		if (src->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info))
+		if (src->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info) &&
+		    src->st_size < sectorsize)
 			btrfs_set_stack_inode_nbytes(dst, src->st_size);
 		else {
 			blocks = src->st_size / sectorsize;
@@ -327,7 +328,8 @@ static int add_file_items(struct btrfs_trans_handle *trans,
 	if (st->st_size % sectorsize)
 		blocks += 1;
 
-	if (st->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info)) {
+	if (st->st_size <= BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info) &&
+	    st->st_size < sectorsize) {
 		char *buffer = malloc(st->st_size);
 
 		if (!buffer) {
-- 
2.16.2


  parent reply	other threads:[~2018-03-20  6:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-20  6:42 [PATCH v3 0/6] Fix long standing -EOPNOTSUPP problem caused by large inline extent Qu Wenruo
2018-03-20  6:42 ` [PATCH v3 1/6] btrfs-progs: convert: Fix inline file extent creation condition Qu Wenruo
2018-03-20  6:42 ` Qu Wenruo [this message]
2018-03-20  6:42 ` [PATCH v3 3/6] btrfs-progs: check/original mode: Check inline extent size Qu Wenruo
2018-03-20  6:42 ` [PATCH v3 4/6] btrfs-progs: check/lowmem " Qu Wenruo
2018-03-20  6:42 ` [PATCH v3 5/6] btrfs-progs: test/convert: Add test case for invalid large inline data extent Qu Wenruo
2018-03-20  6:42 ` [PATCH v3 6/6] btrfs-progs: test/mkfs: Add test case for rootdir inline extent size Qu Wenruo
2018-03-21 15:51 ` [PATCH v3 0/6] Fix long standing -EOPNOTSUPP problem caused by large inline extent David Sterba
2018-03-22  0:12   ` Qu Wenruo
2018-03-22 13:24     ` David Sterba

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=20180320064229.31493-3-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /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).