* [PATCHv2 0/3] nilfs2 add feature flags
@ 2010-07-21 18:22 Ryusuke Konishi
[not found] ` <1279736540-21556-1-git-send-email-konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Ryusuke Konishi @ 2010-07-21 18:22 UTC (permalink / raw)
To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Ryusuke Konishi, Jiro SEKIBA
This is a revised patchset that introduces feature flags and makes
nilfs refuse to mount future incompatibile filesystems.
The first patch is just for improving readability of super block
format. The second patch extends super block and adds three flags to
record feature sets (i.e. "compat features", "read-only compat
features", and "incompat features"). The semantics of these flags is
mimic of ext3. At present, no feature flags are defined.
The third patch makes nilfs reject filesystems with unknown features.
This serves as a safety for future disk format change which is not
forward compatible.
* Change from the v1 patchset is as follows:
- insert the same test of feature flags also before proceed with
recovery for read-only mount.
Thanks,
Ryusuke Konishi
--
fs/nilfs2/nilfs.h | 2 ++
fs/nilfs2/super.c | 39 +++++++++++++++++++++++++++++++++++++++
fs/nilfs2/the_nilfs.c | 20 ++++++++++++++++++++
include/linux/nilfs2_fs.h | 41 +++++++++++++++++++++++++++--------------
4 files changed, 88 insertions(+), 14 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCHv2 1/3] nilfs2: clarify byte offset in super block format
[not found] ` <1279736540-21556-1-git-send-email-konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
@ 2010-07-21 18:22 ` Ryusuke Konishi
2010-07-21 18:22 ` [PATCHv2 2/3] nilfs2: add feature set fields to super block Ryusuke Konishi
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Ryusuke Konishi @ 2010-07-21 18:22 UTC (permalink / raw)
To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Ryusuke Konishi, Jiro SEKIBA
This inserts comments indicating hexadecimal offset in declaration of
nilfs_super_block structure so that people can know offset of its
fields without counting from the head.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
---
include/linux/nilfs2_fs.h | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/include/linux/nilfs2_fs.h b/include/linux/nilfs2_fs.h
index 8c2c611..cc3465e 100644
--- a/include/linux/nilfs2_fs.h
+++ b/include/linux/nilfs2_fs.h
@@ -160,7 +160,7 @@ struct nilfs_super_root {
* struct nilfs_super_block - structure of super block on disk
*/
struct nilfs_super_block {
- __le32 s_rev_level; /* Revision level */
+/*00*/ __le32 s_rev_level; /* Revision level */
__le16 s_minor_rev_level; /* minor revision level */
__le16 s_magic; /* Magic signature */
@@ -169,47 +169,47 @@ struct nilfs_super_block {
is excluded. */
__le16 s_flags; /* flags */
__le32 s_crc_seed; /* Seed value of CRC calculation */
- __le32 s_sum; /* Check sum of super block */
+/*10*/ __le32 s_sum; /* Check sum of super block */
__le32 s_log_block_size; /* Block size represented as follows
blocksize =
1 << (s_log_block_size + 10) */
__le64 s_nsegments; /* Number of segments in filesystem */
- __le64 s_dev_size; /* block device size in bytes */
+/*20*/ __le64 s_dev_size; /* block device size in bytes */
__le64 s_first_data_block; /* 1st seg disk block number */
- __le32 s_blocks_per_segment; /* number of blocks per full segment */
+/*30*/ __le32 s_blocks_per_segment; /* number of blocks per full segment */
__le32 s_r_segments_percentage; /* Reserved segments percentage */
__le64 s_last_cno; /* Last checkpoint number */
- __le64 s_last_pseg; /* disk block addr pseg written last */
+/*40*/ __le64 s_last_pseg; /* disk block addr pseg written last */
__le64 s_last_seq; /* seq. number of seg written last */
- __le64 s_free_blocks_count; /* Free blocks count */
+/*50*/ __le64 s_free_blocks_count; /* Free blocks count */
__le64 s_ctime; /* Creation time (execution time of
newfs) */
- __le64 s_mtime; /* Mount time */
+/*60*/ __le64 s_mtime; /* Mount time */
__le64 s_wtime; /* Write time */
- __le16 s_mnt_count; /* Mount count */
+/*70*/ __le16 s_mnt_count; /* Mount count */
__le16 s_max_mnt_count; /* Maximal mount count */
__le16 s_state; /* File system state */
__le16 s_errors; /* Behaviour when detecting errors */
__le64 s_lastcheck; /* time of last check */
- __le32 s_checkinterval; /* max. time between checks */
+/*80*/ __le32 s_checkinterval; /* max. time between checks */
__le32 s_creator_os; /* OS */
__le16 s_def_resuid; /* Default uid for reserved blocks */
__le16 s_def_resgid; /* Default gid for reserved blocks */
__le32 s_first_ino; /* First non-reserved inode */
- __le16 s_inode_size; /* Size of an inode */
+/*90*/ __le16 s_inode_size; /* Size of an inode */
__le16 s_dat_entry_size; /* Size of a dat entry */
__le16 s_checkpoint_size; /* Size of a checkpoint */
__le16 s_segment_usage_size; /* Size of a segment usage */
- __u8 s_uuid[16]; /* 128-bit uuid for volume */
- char s_volume_name[80]; /* volume name */
+/*98*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
+/*A8*/ char s_volume_name[80]; /* volume name */
- __le32 s_c_interval; /* Commit interval of segment */
+/*F8*/ __le32 s_c_interval; /* Commit interval of segment */
__le32 s_c_block_max; /* Threshold of data amount for
the segment construction */
__u32 s_reserved[192]; /* padding to the end of the block */
--
1.6.6.2
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCHv2 2/3] nilfs2: add feature set fields to super block
[not found] ` <1279736540-21556-1-git-send-email-konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2010-07-21 18:22 ` [PATCHv2 1/3] nilfs2: clarify byte offset in super block format Ryusuke Konishi
@ 2010-07-21 18:22 ` Ryusuke Konishi
2010-07-21 18:22 ` [PATCHv2 3/3] nilfs2: reject incompatible filesystem Ryusuke Konishi
2010-07-23 4:30 ` [PATCHv2 0/3] nilfs2 add feature flags Jiro SEKIBA
3 siblings, 0 replies; 6+ messages in thread
From: Ryusuke Konishi @ 2010-07-21 18:22 UTC (permalink / raw)
To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Ryusuke Konishi, Jiro SEKIBA
This adds three new fields to nilfs_super_block structure, compatible
feature set, readonly-compatible feature set, and incompatible feature
set in order to prepare for future disk format modifications.
The role of these fields conforms to those of ext3 or other
filesystems. Most important flags are the incompatible feature set;
it is used to refuse to mount the filesystem which sets an
incompatible feature the kernel doesn't know about.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
---
include/linux/nilfs2_fs.h | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/include/linux/nilfs2_fs.h b/include/linux/nilfs2_fs.h
index cc3465e..7dd4cd4 100644
--- a/include/linux/nilfs2_fs.h
+++ b/include/linux/nilfs2_fs.h
@@ -212,7 +212,10 @@ struct nilfs_super_block {
/*F8*/ __le32 s_c_interval; /* Commit interval of segment */
__le32 s_c_block_max; /* Threshold of data amount for
the segment construction */
- __u32 s_reserved[192]; /* padding to the end of the block */
+/*100*/ __le64 s_feature_compat; /* Compatible feature set */
+ __le64 s_feature_compat_ro; /* Read-only compatible feature set */
+ __le64 s_feature_incompat; /* Incompatible feature set */
+ __u32 s_reserved[186]; /* padding to the end of the block */
};
/*
@@ -228,6 +231,16 @@ struct nilfs_super_block {
#define NILFS_MINOR_REV 0 /* minor revision */
/*
+ * Feature set definitions
+ *
+ * If there is a bit set in the incompatible feature set that the kernel
+ * doesn't know about, it should refuse to mount the filesystem.
+ */
+#define NILFS_FEATURE_COMPAT_SUPP 0ULL
+#define NILFS_FEATURE_COMPAT_RO_SUPP 0ULL
+#define NILFS_FEATURE_INCOMPAT_SUPP 0ULL
+
+/*
* Bytes count of super_block for CRC-calculation
*/
#define NILFS_SB_BYTES \
--
1.6.6.2
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCHv2 3/3] nilfs2: reject incompatible filesystem
[not found] ` <1279736540-21556-1-git-send-email-konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2010-07-21 18:22 ` [PATCHv2 1/3] nilfs2: clarify byte offset in super block format Ryusuke Konishi
2010-07-21 18:22 ` [PATCHv2 2/3] nilfs2: add feature set fields to super block Ryusuke Konishi
@ 2010-07-21 18:22 ` Ryusuke Konishi
2010-07-23 4:30 ` [PATCHv2 0/3] nilfs2 add feature flags Jiro SEKIBA
3 siblings, 0 replies; 6+ messages in thread
From: Ryusuke Konishi @ 2010-07-21 18:22 UTC (permalink / raw)
To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA; +Cc: Ryusuke Konishi, Jiro SEKIBA
This forces nilfs to check compatibility of feature flags so as to
reject a filesystem with unknown features when it mounts or remounts
the filesystem.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
---
fs/nilfs2/nilfs.h | 2 ++
fs/nilfs2/super.c | 39 +++++++++++++++++++++++++++++++++++++++
fs/nilfs2/the_nilfs.c | 20 ++++++++++++++++++++
3 files changed, 61 insertions(+), 0 deletions(-)
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index cfedc48..0842d77 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -275,6 +275,8 @@ extern struct nilfs_super_block *
nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **);
extern int nilfs_store_magic_and_option(struct super_block *,
struct nilfs_super_block *, char *);
+extern int nilfs_check_feature_compatibility(struct super_block *,
+ struct nilfs_super_block *);
extern void nilfs_set_log_cursor(struct nilfs_super_block *,
struct the_nilfs *);
extern struct nilfs_super_block **nilfs_prepare_super(struct nilfs_sb_info *,
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 1644573..26078b3 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -790,6 +790,30 @@ int nilfs_store_magic_and_option(struct super_block *sb,
return !parse_options(data, sb, 0) ? -EINVAL : 0 ;
}
+int nilfs_check_feature_compatibility(struct super_block *sb,
+ struct nilfs_super_block *sbp)
+{
+ __u64 features;
+
+ features = le64_to_cpu(sbp->s_feature_incompat) &
+ ~NILFS_FEATURE_INCOMPAT_SUPP;
+ if (features) {
+ printk(KERN_ERR "NILFS: couldn't mount because of unsupported "
+ "optional features (%llx)\n",
+ (unsigned long long)features);
+ return -EINVAL;
+ }
+ features = le64_to_cpu(sbp->s_feature_compat_ro) &
+ ~NILFS_FEATURE_COMPAT_RO_SUPP;
+ if (!(sb->s_flags & MS_RDONLY) && features) {
+ printk(KERN_ERR "NILFS: couldn't mount RDWR because of "
+ "unsupported optional features (%llx)\n",
+ (unsigned long long)features);
+ return -EINVAL;
+ }
+ return 0;
+}
+
/**
* nilfs_fill_super() - initialize a super block instance
* @sb: super_block
@@ -984,11 +1008,26 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
nilfs_cleanup_super(sbi);
up_write(&nilfs->ns_sem);
} else {
+ __u64 features;
+
/*
* Mounting a RDONLY partition read-write, so reread and
* store the current valid flag. (It may have been changed
* by fsck since we originally mounted the partition.)
*/
+ down_read(&nilfs->ns_sem);
+ features = le64_to_cpu(nilfs->ns_sbp[0]->s_feature_compat_ro) &
+ ~NILFS_FEATURE_COMPAT_RO_SUPP;
+ up_read(&nilfs->ns_sem);
+ if (features) {
+ printk(KERN_WARNING "NILFS (device %s): couldn't "
+ "remount RDWR because of unsupported optional "
+ "features (%llx)\n",
+ sb->s_id, (unsigned long long)features);
+ err = -EROFS;
+ goto restore_opts;
+ }
+
sb->s_flags &= ~MS_RDONLY;
err = nilfs_attach_segment_constructor(sbi);
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index f2efc8c..da67b56 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -385,11 +385,23 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)
goto skip_recovery;
if (s_flags & MS_RDONLY) {
+ __u64 features;
+
if (nilfs_test_opt(sbi, NORECOVERY)) {
printk(KERN_INFO "NILFS: norecovery option specified. "
"skipping roll-forward recovery\n");
goto skip_recovery;
}
+ features = le64_to_cpu(nilfs->ns_sbp[0]->s_feature_compat_ro) &
+ ~NILFS_FEATURE_COMPAT_RO_SUPP;
+ if (features) {
+ printk(KERN_ERR "NILFS: couldn't proceed with "
+ "recovery because of unsupported optional "
+ "features (%llx)\n",
+ (unsigned long long)features);
+ err = -EROFS;
+ goto failed_unload;
+ }
if (really_read_only) {
printk(KERN_ERR "NILFS: write access "
"unavailable, cannot proceed.\n");
@@ -644,6 +656,10 @@ int init_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi, char *data)
if (err)
goto out;
+ err = nilfs_check_feature_compatibility(sb, sbp);
+ if (err)
+ goto out;
+
blocksize = BLOCK_SIZE << le32_to_cpu(sbp->s_log_block_size);
if (sb->s_blocksize != blocksize &&
!sb_set_blocksize(sb, blocksize)) {
@@ -669,6 +685,10 @@ int init_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi, char *data)
if (err)
goto failed_sbh;
+ err = nilfs_check_feature_compatibility(sb, sbp);
+ if (err)
+ goto failed_sbh;
+
blocksize = BLOCK_SIZE << le32_to_cpu(sbp->s_log_block_size);
if (sb->s_blocksize != blocksize) {
int hw_blocksize = bdev_logical_block_size(sb->s_bdev);
--
1.6.6.2
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCHv2 0/3] nilfs2 add feature flags
[not found] ` <1279736540-21556-1-git-send-email-konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
` (2 preceding siblings ...)
2010-07-21 18:22 ` [PATCHv2 3/3] nilfs2: reject incompatible filesystem Ryusuke Konishi
@ 2010-07-23 4:30 ` Jiro SEKIBA
[not found] ` <87tynq95wy.wl%jir-27yqGEOhnJbQT0dZR+AlfA@public.gmane.org>
3 siblings, 1 reply; 6+ messages in thread
From: Jiro SEKIBA @ 2010-07-23 4:30 UTC (permalink / raw)
To: Ryusuke Konishi; +Cc: linux-nilfs-u79uwXL29TY76Z2rM5mHXA
Hi,
At Thu, 22 Jul 2010 03:22:17 +0900,
Ryusuke Konishi wrote:
>
> This is a revised patchset that introduces feature flags and makes
> nilfs refuse to mount future incompatibile filesystems.
>
> The first patch is just for improving readability of super block
> format. The second patch extends super block and adds three flags to
> record feature sets (i.e. "compat features", "read-only compat
> features", and "incompat features"). The semantics of these flags is
> mimic of ext3. At present, no feature flags are defined.
>
> The third patch makes nilfs reject filesystems with unknown features.
> This serves as a safety for future disk format change which is not
> forward compatible.
>
> * Change from the v1 patchset is as follows:
>
> - insert the same test of feature flags also before proceed with
> recovery for read-only mount.
This is, I think, one of the mandatory functionality to take
"experimental flag" away. Fixing disk format is important,
but any unexpected incompatible disk format change may happen in future.
At least, nilfs can protect its filesystem from destructing by itself.
Thank you for the improvement!
> Thanks,
> Ryusuke Konishi
> --
> fs/nilfs2/nilfs.h | 2 ++
> fs/nilfs2/super.c | 39 +++++++++++++++++++++++++++++++++++++++
> fs/nilfs2/the_nilfs.c | 20 ++++++++++++++++++++
> include/linux/nilfs2_fs.h | 41 +++++++++++++++++++++++++++--------------
> 4 files changed, 88 insertions(+), 14 deletions(-)
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
>
--
Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv2 0/3] nilfs2 add feature flags
[not found] ` <87tynq95wy.wl%jir-27yqGEOhnJbQT0dZR+AlfA@public.gmane.org>
@ 2010-07-23 13:28 ` Ryusuke Konishi
0 siblings, 0 replies; 6+ messages in thread
From: Ryusuke Konishi @ 2010-07-23 13:28 UTC (permalink / raw)
To: jir-hfpbi5WX9J54Eiagz67IpQ
Cc: konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg,
linux-nilfs-u79uwXL29TY76Z2rM5mHXA
On Fri, 23 Jul 2010 13:30:05 +0900, Jiro SEKIBA wrote:
> Hi,
>
> At Thu, 22 Jul 2010 03:22:17 +0900,
> Ryusuke Konishi wrote:
> >
> > This is a revised patchset that introduces feature flags and makes
> > nilfs refuse to mount future incompatibile filesystems.
> >
> > The first patch is just for improving readability of super block
> > format. The second patch extends super block and adds three flags to
> > record feature sets (i.e. "compat features", "read-only compat
> > features", and "incompat features"). The semantics of these flags is
> > mimic of ext3. At present, no feature flags are defined.
> >
> > The third patch makes nilfs reject filesystems with unknown features.
> > This serves as a safety for future disk format change which is not
> > forward compatible.
> >
> > * Change from the v1 patchset is as follows:
> >
> > - insert the same test of feature flags also before proceed with
> > recovery for read-only mount.
>
> This is, I think, one of the mandatory functionality to take
> "experimental flag" away. Fixing disk format is important,
> but any unexpected incompatible disk format change may happen in future.
>
> At least, nilfs can protect its filesystem from destructing by itself.
Yes, that's the reason why I push it now.
All right, I'll queue it for the next merge window as planned.
Thanks,
Ryusuke Konishi
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-07-23 13:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-21 18:22 [PATCHv2 0/3] nilfs2 add feature flags Ryusuke Konishi
[not found] ` <1279736540-21556-1-git-send-email-konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2010-07-21 18:22 ` [PATCHv2 1/3] nilfs2: clarify byte offset in super block format Ryusuke Konishi
2010-07-21 18:22 ` [PATCHv2 2/3] nilfs2: add feature set fields to super block Ryusuke Konishi
2010-07-21 18:22 ` [PATCHv2 3/3] nilfs2: reject incompatible filesystem Ryusuke Konishi
2010-07-23 4:30 ` [PATCHv2 0/3] nilfs2 add feature flags Jiro SEKIBA
[not found] ` <87tynq95wy.wl%jir-27yqGEOhnJbQT0dZR+AlfA@public.gmane.org>
2010-07-23 13:28 ` Ryusuke Konishi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.