linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 3/3] f2fs: allow zeroed name length during find_dentry
Date: Wed, 15 Jul 2015 15:38:12 -0700	[thread overview]
Message-ID: <1436999892-86682-3-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1436999892-86682-1-git-send-email-jaegeuk@kernel.org>

Since find_dentry doesn't lock its dentry page, it can traverse intermediate
bit positions consisting of a big dentry.
For these bit positions, this patch fills the intermediate name length fields
as zeros and skips them during look-up.

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

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index a34ebd8..71195f5 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -141,11 +141,15 @@ struct f2fs_dir_entry *find_target_dentry(struct f2fs_filename *fname,
 			*max_slots = max_len;
 		max_len = 0;
 
-		/* remain bug on condition */
-		if (unlikely(!de->name_len))
-			d->max = -1;
-
-		bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
+		/*
+		 * While a large dentry is adding, it can traverse its valid bit
+		 * positions, since find_entry does not lock its dentry page.
+		 * In that case, let's skip the bit position.
+		 */
+		if (de_name.len == 0)
+			bit_pos++;
+		else
+			bit_pos += GET_DENTRY_SLOTS(de_name.len);
 	}
 
 	de = NULL;
@@ -505,8 +509,12 @@ void f2fs_update_dentry(nid_t ino, umode_t mode, struct f2fs_dentry_ptr *d,
 	memcpy(d->filename[bit_pos], name->name, name->len);
 	de->ino = cpu_to_le32(ino);
 	set_de_type(de, mode);
-	for (i = 0; i < slots; i++)
+	for (i = 0; i < slots; i++) {
+		/* fill zeros for intermediate name_len slots */
+		if (i >= 1)
+			d->dentry[bit_pos + i].name_len = 0;
 		test_and_set_bit_le(bit_pos + i, (void *)d->bitmap);
+	}
 }
 
 /*
-- 
2.1.1

  parent reply	other threads:[~2015-07-15 22:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-15 22:38 [PATCH 1/3] f2fs: callers take care of the page from bio error Jaegeuk Kim
2015-07-15 22:38 ` [PATCH 2/3] f2fs: handle error cases in move_encrypted_block Jaegeuk Kim
2015-07-16 10:02   ` [f2fs-dev] " Chao Yu
2015-07-15 22:38 ` Jaegeuk Kim [this message]
2015-07-16 10:03   ` [f2fs-dev] [PATCH 3/3] f2fs: allow zeroed name length during find_dentry Chao Yu
2015-07-17  1:57     ` Jaegeuk Kim
2015-07-16 10:00 ` [f2fs-dev] [PATCH 1/3] f2fs: callers take care of the page from bio error Chao Yu

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=1436999892-86682-3-git-send-email-jaegeuk@kernel.org \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@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).