From patchwork Wed Jul 15 22:38:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 6800901 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1482B9F2E8 for ; Wed, 15 Jul 2015 22:38:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35B6920661 for ; Wed, 15 Jul 2015 22:38:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 528A12065A for ; Wed, 15 Jul 2015 22:38:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753836AbbGOWi3 (ORCPT ); Wed, 15 Jul 2015 18:38:29 -0400 Received: from mail.kernel.org ([198.145.29.136]:33831 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753804AbbGOWiW (ORCPT ); Wed, 15 Jul 2015 18:38:22 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E23020661; Wed, 15 Jul 2015 22:38:21 +0000 (UTC) Received: from localhost (mobile-166-171-251-097.mycingular.net [166.171.251.97]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6DCAC2061E; Wed, 15 Jul 2015 22:38:20 +0000 (UTC) From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH 3/3] f2fs: allow zeroed name length during find_dentry Date: Wed, 15 Jul 2015 15:38:12 -0700 Message-Id: <1436999892-86682-3-git-send-email-jaegeuk@kernel.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1436999892-86682-1-git-send-email-jaegeuk@kernel.org> References: <1436999892-86682-1-git-send-email-jaegeuk@kernel.org> X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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); + } } /*