From patchwork Fri Apr 5 05:54:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 2396771 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 13A69E00D8 for ; Fri, 5 Apr 2013 05:53:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1765499Ab3DEFxs (ORCPT ); Fri, 5 Apr 2013 01:53:48 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:38571 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751366Ab3DEFxr (ORCPT ); Fri, 5 Apr 2013 01:53:47 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r355rkQG001764 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 5 Apr 2013 05:53:47 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r355rjtO005028 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 5 Apr 2013 05:53:46 GMT Received: from abhmt104.oracle.com (abhmt104.oracle.com [141.146.116.56]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r355rjfv017065 for ; Fri, 5 Apr 2013 00:53:45 -0500 Received: from wish.sg.oracle.com (/10.186.101.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 04 Apr 2013 22:53:45 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/9] [RESEND] btrfs-progs: root_item generation_v2 is out of sync after btrfsck Date: Fri, 5 Apr 2013 13:54:55 +0800 Message-Id: <1365141303-10571-2-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 1.8.1.164.g2d0029e In-Reply-To: <1365141303-10571-1-git-send-email-anand.jain@oracle.com> References: <1365141303-10571-1-git-send-email-anand.jain@oracle.com> X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org reproducing steps: mkfs.btrfs /dev/dm-2 -f mount /dev/dm-2 /btrfs umount /btrfs btrfs check /dev/dm-2 --repair mount /dev/dm-2 /btrfs ---- btrfs: mismatching generation and generation_v2 found in root item. This root was probably mounted with an older kernel. Resetting all new fields. ---- btrfs-debug-tree shows change in uuid < root data bytenr 29425664 level 0 dirid 0 refs 1 gen 43 < uuid 293596e8-7888-eb4c-9134-6df9db996fe5 Signed-off-by: Anand Jain --- root-tree.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/root-tree.c b/root-tree.c index c10d068..4454147 100644 --- a/root-tree.c +++ b/root-tree.c @@ -69,6 +69,7 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root int ret; int slot; unsigned long ptr; + u32 old_size; path = btrfs_alloc_path(); BUG_ON(!path); @@ -79,6 +80,18 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root l = path->nodes[0]; slot = path->slots[0]; ptr = btrfs_item_ptr_offset(l, slot); + /* + * If the btrfs-progs is newer and kernel is at + * generation_v1 then we don't touch v2 items + * otherwise when kernel is at same or greater + * version compared with btrfs-progs then update + * the needed + */ + old_size = btrfs_item_size_nr(l, slot); + if (old_size >= sizeof(*item)) { + btrfs_set_root_generation_v2(item, + btrfs_root_generation(item)); + } write_extent_buffer(l, item, ptr, sizeof(*item)); btrfs_mark_buffer_dirty(path->nodes[0]); out: