From patchwork Tue Mar 6 15:18:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Blagodarenko X-Patchwork-Id: 882110 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lq9G5M81"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zwgRR5X31z9skx for ; Wed, 7 Mar 2018 02:19:15 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932313AbeCFPTO (ORCPT ); Tue, 6 Mar 2018 10:19:14 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33569 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932147AbeCFPS4 (ORCPT ); Tue, 6 Mar 2018 10:18:56 -0500 Received: by mail-lf0-f68.google.com with SMTP id o145so29033103lff.0 for ; Tue, 06 Mar 2018 07:18:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hxggAYsNRJkoS9YmIEMzrWrwvSWLdwL2/SlQXYH8yJU=; b=lq9G5M81enHNe1NyLmPB2BdULpCcDe1SaqT8Ai1fh4MaQPR/QU3m1KXCGVJv3o8uEN +v3stKPfk8vLsDFUQcklVYQzbolQ16jROjxj1kIQ+qWPMEFH2qlxkXNGGu73uVqYQ+63 JKuh+awUly9dap4b6/9M5n2hsBxxZbjZuTVlK441HU8ayCyCeQSTgu/NGOfwSNxNiQ7L W3CYFJ4xSeE9RcPMqro8yew111CWvP51yPsIANKOOLwmp8lXPsST5CZnZHqrnqjWNRxn YzoeoBiZEoNAeQwpKlh+eMnHcdBRg+QqrsqUwJCNs2N3tZ3B5/uf0kFFbqvBgvFIsDeA SPig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hxggAYsNRJkoS9YmIEMzrWrwvSWLdwL2/SlQXYH8yJU=; b=MhreWPp3O+27IeGwQohzLSQG6xN+KhCIBJt7UpkcDb2qB4VNYKjSWqBrsvAQRgdsjs XMiUa9v7tHBK5p1Pkcbd/YCICgSkDW9xlIyhRX4svxw4TVZwxTLDXs093gfQUWmH7l55 yiFopbIjnNMrNDTFb/NoGns8V6ZUFqIvT2zdhjYG78XFT3iAvoYEw7mpNb2nSj9opsK7 QdQEx6ip85b5PndMh3C9wFmXHjzJ58oy/P1dX6KnNVn42Zpeib7ZxDGfYaXf5xtSdosX zhsZYtEsHwNN3a8OGuCkWnToD8ECTzHif+jQlbD3jyyf6ABtUS3AymsenqoCXSk7Licv Fr9g== X-Gm-Message-State: APf1xPA6MiV3fQSW952WhErwqg8DvAfezAOb8MUpIRk41X/oWVZ9f2xF GmwBE4b2XTScsLuf8KXpI+S+Uw== X-Google-Smtp-Source: AG47ELtC1IyqTLuHFALg5OFJxaBkiytXEYasqxxe6+li9PrwcgCftp3xSYOxAL7j0H/uTQkZI7MjRA== X-Received: by 10.46.41.157 with SMTP id p29mr12498480ljp.137.1520349534104; Tue, 06 Mar 2018 07:18:54 -0800 (PST) Received: from C02TN4C6HTD6.lan ([80.72.234.202]) by smtp.gmail.com with ESMTPSA id m1sm3187259lje.66.2018.03.06.07.18.52 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 06 Mar 2018 07:18:53 -0800 (PST) From: Artem Blagodarenko To: linux-ext4@vger.kernel.org Cc: adilger.kernel@dilger.ca Subject: [PATCH v3 7/7] ext2fs: last_oraph 64bit support Date: Tue, 6 Mar 2018 18:18:35 +0300 Message-Id: <20180306151835.4842-8-artem.blagodarenko@gmail.com> X-Mailer: git-send-email 2.14.3 (Apple Git-98) In-Reply-To: <20180306151835.4842-1-artem.blagodarenko@gmail.com> References: <20180306151835.4842-1-artem.blagodarenko@gmail.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This patch is required by INODE64 feature. High part of last_oraph is stored in superblock and accessed using helper functions. Lustre-bug: https://jira.hpdd.intel.com/browse/LU-9309 Signed-off-by: Artem Blagodarenko Reviewed-by: Andreas Dilger --- e2fsck/pass1.c | 4 ++-- e2fsck/super.c | 7 ++++--- lib/e2p/ls.c | 4 ++-- lib/ext2fs/ext2_fs.h | 3 ++- lib/ext2fs/ext2fs.h | 19 +++++++++++++++++++ lib/ext2fs/swapfs.c | 1 + lib/ext2fs/tst_super_size.c | 3 ++- misc/fuse2fs.c | 2 +- 8 files changed, 33 insertions(+), 10 deletions(-) diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 24f8e215..20823724 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -1301,8 +1301,8 @@ void e2fsck_pass1(e2fsck_t ctx) * ext3 mount code won't get confused. */ if (!(ctx->options & E2F_OPT_READONLY)) { - if (fs->super->s_last_orphan) { - fs->super->s_last_orphan = 0; + if (ext2fs_get_last_orphan(fs->super)) { + ext2fs_set_last_orphan(fs->super, 0); ext2fs_mark_super_dirty(fs); } } diff --git a/e2fsck/super.c b/e2fsck/super.c index 7183755c..e1ba8887 100644 --- a/e2fsck/super.c +++ b/e2fsck/super.c @@ -248,19 +248,20 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino, static int release_orphan_inodes(e2fsck_t ctx) { ext2_filsys fs = ctx->fs; - ext2_ino_t ino, next_ino; + ext2_ino64_t ino, next_ino; struct ext2_inode inode; struct problem_context pctx; char *block_buf; - if ((ino = fs->super->s_last_orphan) == 0) + ino = ext2fs_get_last_orphan(fs->super); + if (ino == 0) return 0; /* * Win or lose, we won't be using the head of the orphan inode * list again. */ - fs->super->s_last_orphan = 0; + ext2fs_set_last_orphan(fs->super, 0); ext2fs_mark_super_dirty(fs); /* diff --git a/lib/e2p/ls.c b/lib/e2p/ls.c index 91a3b0ae..5300b126 100644 --- a/lib/e2p/ls.c +++ b/lib/e2p/ls.c @@ -377,9 +377,9 @@ void list_super2(struct ext2_super_block * sb, FILE *f) if (sb->s_journal_dev) fprintf(f, "Journal device: 0x%04x\n", sb->s_journal_dev); - if (sb->s_last_orphan) + if (ext2fs_get_last_orphan(sb)) fprintf(f, "First orphan inode: %u\n", - sb->s_last_orphan); + ext2fs_get_last_orphan(sb)); if (ext2fs_has_feature_dir_index(sb) || sb->s_def_hash_version) fprintf(f, "Default directory hash: %s\n", diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index 1fadae53..f528400b 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -740,7 +740,8 @@ struct ext2_super_block { __le32 s_inodes_count_hi; /* high part of inode count */ __le32 s_free_inodes_count_hi; /* Free inodes count */ __le32 s_prj_quota_inum_hi; /* high part of project quota inode */ - __le32 s_reserved[95]; /* Padding to the end of the block */ + __le32 s_last_orphan_hi; /* high part of last orphan */ + __le32 s_reserved[94]; /* Padding to the end of the block */ __u32 s_checksum; /* crc32c(superblock) */ }; diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index f5deb650..2e479249 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -2085,6 +2085,25 @@ static inline void ext2fs_set_free_inodes_count(struct ext2_super_block *sb, sb->s_free_inodes_count = val; } +static inline ext2_ino64_t +ext2fs_get_last_orphan(struct ext2_super_block *sb) +{ + ext2_ino64_t last_orphan = sb->s_last_orphan; + + if (ext2fs_has_feature_inode64(sb)) + last_orphan |= (ext2_ino64_t)sb->s_last_orphan_hi << 32; + return last_orphan; +} + +static inline void ext2fs_set_last_orphan(struct ext2_super_block *sb, + ext2_ino64_t val) +{ + if (ext2fs_has_feature_inode64(sb)) + sb->s_last_orphan_hi = (__u32)(val >> 32); + sb->s_last_orphan = val; +} + + static inline void ext2fs_inc_free_inodes_count(struct ext2_super_block *sb) { __u64 val = ext2fs_get_free_inodes_count(sb); diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c index 4243e65a..07e4e77d 100644 --- a/lib/ext2fs/swapfs.c +++ b/lib/ext2fs/swapfs.c @@ -85,6 +85,7 @@ void ext2fs_swap_super(struct ext2_super_block * sb) sb->s_overhead_blocks = ext2fs_swab32(sb->s_overhead_blocks); sb->s_inodes_count_hi = ext2fs_swab32(sb->s_inodes_count_hi); sb->s_free_inodes_count_hi = ext2fs_swab32(sb->s_free_inodes_count_hi); + sb->s_last_orphan_hi = ext2fs_swab32(sb->s_last_orphan_hi); sb->s_checksum = ext2fs_swab32(sb->s_checksum); for (i=0; i < 4; i++) diff --git a/lib/ext2fs/tst_super_size.c b/lib/ext2fs/tst_super_size.c index 1fa49bb2..0908e254 100644 --- a/lib/ext2fs/tst_super_size.c +++ b/lib/ext2fs/tst_super_size.c @@ -145,7 +145,8 @@ int main(int argc, char **argv) check_field(s_inodes_count_hi, 4); check_field(s_free_inodes_count_hi, 4); check_field(s_prj_quota_inum_hi, 4); - check_field(s_reserved, 95 * 4); + check_field(s_last_orphan_hi, 4); + check_field(s_reserved, 94 * 4); check_field(s_checksum, 4); do_field("Superblock end", 0, 0, cur_offset, 1024); #endif diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index bb21e2b4..7c3f3b52 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -3822,7 +3822,7 @@ int main(int argc, char *argv[]) global_fs->super->s_checkinterval) <= time(0)) printf("%s", _("Warning: Check time reached; running e2fsck " "is recommended.\n")); - if (global_fs->super->s_last_orphan) + if (ext2fs_get_last_orphan(global_fs->super)) printf("%s", _("Orphans detected; running e2fsck is recommended.\n"));