From: Hin-Tak Leung Subject: Re: [PATCH] hfsplus: add journal replay Date: Sun, 23 Feb 2014 04:58:39 +0000 (GMT) Message-ID: <1393131519.58633.YahooMailBasic@web172302.mail.ir2.yahoo.com> Reply-To: htl10@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: viro@zeniv.linux.org.uk, hch@infradead.org, akpm@linux-foundation.org, slava@dubeyko.com To: saproj@gmail.com, linux-fsdevel@vger.kernel.org Return-path: Received: from nm48.bullet.mail.ne1.yahoo.com ([98.138.120.55]:22483 "HELO nm48.bullet.mail.ne1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1750723AbaBWFBV convert rfc822-to-8bit (ORCPT ); Sun, 23 Feb 2014 00:01:21 -0500 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: ------------------------------ On Sun, Feb 23, 2014 2:26 AM GMT Sergei Antonov wrote: >Add journal replay functionality. If filesystem is mounted for read-wr= ite and >a non-empty journal is found, the replay action will be done. The orig= inal >behaviour of switching to read-only mode in presense of journal by def= ault is >retained since the driver does not support journaled metadata modifica= tion >anyway. After an attempt to replay has been done, the mount procedure = repeats >loading volume header to get its updated state. Having performed journ= al replay >we do not run a risk of stumbling on inconsistency when working with t= he volume, >so this functionality adds stability, while not changing any existing = behaviour. >Mount logic in super.c is changed as conservatively as possible. > >The replay code checks the integrity of the whole journal before actua= lly >replaying sectors. If any error (e.g. checksum mismatch, invalid/misal= igned >offsets) is detected, the volume will remain unchanged and the journal= will not >be cleared. > >The code supports checksums for replay data in addition to checksums f= or header >and lists. Checksums for data is a relatively modern feature present o= n volumes >modified by modern OS X versions. > >Tested with: > drives with 512 and 4K sector sizes > default (8 MB) and custom (1 MB, 500 MB) journal sizes > big-endian (PowerPC) and little-endian (Intel) journal byte sexes > >Advantages over a previously presented >=A0=A0=A0"[PATCH v3 00/15] hfsplus: introduce journal replay functiona= lity" >=A0=A0=A0by a different author: > support for big-endian journal > no redundant stuff like journal initialization > less intrusive changes > shorter, easier to review > >Signed-off-by: Sergei Antonov >CC: Al Viro >CC: Christoph Hellwig >CC: Andrew Morton >CC: Vyacheslav Dubeyko >CC: Hin-Tak Leung Acked-by: Hin-Tak Leung I appreciate you have done further work on the byte-swapping in the big-endian journals. Since you are not updating the journal header with its original endianness (I don't know whether this is a good thing or not - would like to know what the darwin kernel does), it seems that there is no need to keep journal_swab around in the super-block. Another comment below. >--- > fs/hfsplus/Makefile=A0 =A0 =A0 |=A0=A0=A03 +- > fs/hfsplus/hfsplus_fs.h=A0 |=A0=A0=A09 + > fs/hfsplus/hfsplus_raw.h |=A0 65 +++- > fs/hfsplus/journal.c=A0 =A0=A0=A0| 903 ++++++++++++++++++++++++++++++= +++++++++++++++++ > fs/hfsplus/super.c=A0 =A0 =A0=A0=A0|=A0 30 +- > 5 files changed, 1004 insertions(+), 6 deletions(-) > create mode 100644 fs/hfsplus/journal.c > >diff --git a/fs/hfsplus/Makefile b/fs/hfsplus/Makefile >index 683fca2..927e89c 100644 >--- a/fs/hfsplus/Makefile >+++ b/fs/hfsplus/Makefile >@@ -6,6 +6,7 @@ obj-$(CONFIG_HFSPLUS_FS) +=3D hfsplus.o >=20 > hfsplus-objs :=3D super.o options.o inode.o ioctl.o extents.o catalog= =2Eo dir.o btree.o \ > =A0=A0=A0 =A0=A0=A0 bnode.o brec.o bfind.o tables.o unicode.o wrapper= =2Eo bitmap.o part_tbl.o \ >-=A0=A0=A0 =A0=A0=A0 attributes.o xattr.o xattr_user.o xattr_security.= o xattr_trusted.o >+=A0=A0=A0 =A0=A0=A0 attributes.o xattr.o xattr_user.o xattr_security.= o xattr_trusted.o \ >+=A0=A0=A0 =A0=A0=A0 journal.o >=20 > hfsplus-$(CONFIG_HFSPLUS_FS_POSIX_ACL)=A0=A0=A0 +=3D posix_acl.o >diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h >index 08846425b..2edbfd1 100644 >--- a/fs/hfsplus/hfsplus_fs.h >+++ b/fs/hfsplus/hfsplus_fs.h =2E.. >@@ -166,6 +167,11 @@ struct hfsplus_sb_info { > =A0=A0=A0 u32 total_blocks; > =A0=A0=A0 u32 data_clump_blocks, rsrc_clump_blocks; >=20 >+=A0=A0=A0 /* immutable data on the placement of the journal (if there= is one) */ >+=A0=A0=A0 u64 journal_offset;=A0=A0=A0 /* relative to volume start */ >+=A0=A0=A0 u64 journal_size;=A0=A0=A0 /* relative to volume start */ >+=A0=A0=A0 bool journal_swab;=A0=A0=A0 /* need swap bytes in journal *= / >+ > =A0=A0=A0 /* mutable data from the volume header, protected by alloc_= mutex */ > =A0=A0=A0 u32 free_blocks; > =A0=A0=A0 struct mutex alloc_mutex; =2E.. >--- a/fs/hfsplus/hfsplus_raw.h >+++ b/fs/hfsplus/hfsplus_raw.h >@@ -105,7 +105,7 @@ struct hfsplus_vh { > =A0=A0=A0 __be16 version; > =A0=A0=A0 __be32 attributes; > =A0=A0=A0 __be32 last_mount_vers; >-=A0=A0=A0 u32 reserved; >+=A0=A0=A0 __be32 jrnl_info_block; >=20 > =A0=A0=A0 __be32 create_date; > =A0=A0=A0 __be32 modify_date; >@@ -145,6 +145,69 @@ struct hfsplus_vh { > #define HFSPLUS_VOL_JOURNALED=A0=A0=A0 =A0=A0=A0 (1 < 13) > #define HFSPLUS_VOL_SOFTLOCK=A0=A0=A0 =A0=A0=A0 (1 < 15) >=20 >+/* Journal info */ >+struct hfs_jrnl_info { >+=A0=A0=A0 __be32 flags; >+=A0=A0=A0 u32 unused[8]; >+=A0=A0=A0 __be64 journal_offset;=A0=A0=A0 /* Misaligned! relative to = volume start */ >+=A0=A0=A0 __be64 journal_size;=A0=A0=A0 /* Misaligned! relative to vo= lume start */ >+} __packed; >+ =2E.. Storing journal_offset and journal_size in two places seems redundant - the journal info block is part of the volume header struct, which is = accessible from the superblock struct. There are one or two spelling mistakes in one of the comments, as well as some grammar issues.=20 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html