aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTiger Yang <tiger.yang@oracle.com>2008-08-18 05:11:46 -0400
committerMark Fasheh <mfasheh@suse.com>2008-10-13 19:57:03 -0400
commit8154da3d2114241cf3edb108b43e2172be86d483 (patch)
treea6d1c1652469d9a34b50dbdab4a435376bf3f32c /fs
parenta394425643e1e9c3a624d629fc8ba5633d8474c6 (diff)
ocfs2: Add incompatible flag for extended attribute
This patch adds the s_incompat flag for extended attribute support. This helps us ensure that older versions of Ocfs2 or ocfs2-tools will not be able to mount a volume with xattr support. Signed-off-by: Tiger Yang <tiger.yang@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/ocfs2.h7
-rw-r--r--fs/ocfs2/ocfs2_fs.h19
-rw-r--r--fs/ocfs2/super.c3
-rw-r--r--fs/ocfs2/xattr.c12
4 files changed, 34 insertions, 7 deletions
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index cae0dd4b7f75..6d3c10ddf489 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -363,6 +363,13 @@ static inline int ocfs2_supports_inline_data(struct ocfs2_super *osb)
363 return 0; 363 return 0;
364} 364}
365 365
366static inline int ocfs2_supports_xattr(struct ocfs2_super *osb)
367{
368 if (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_XATTR)
369 return 1;
370 return 0;
371}
372
366/* set / clear functions because cluster events can make these happen 373/* set / clear functions because cluster events can make these happen
367 * in parallel so we want the transitions to be atomic. this also 374 * in parallel so we want the transitions to be atomic. this also
368 * means that any future flags osb_flags must be protected by spinlock 375 * means that any future flags osb_flags must be protected by spinlock
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h
index 8d5e72f2c5cf..f24ce3d3f956 100644
--- a/fs/ocfs2/ocfs2_fs.h
+++ b/fs/ocfs2/ocfs2_fs.h
@@ -91,7 +91,8 @@
91 | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \ 91 | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \
92 | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \ 92 | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \
93 | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \ 93 | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \
94 | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK) 94 | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \
95 | OCFS2_FEATURE_INCOMPAT_XATTR)
95#define OCFS2_FEATURE_RO_COMPAT_SUPP OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 96#define OCFS2_FEATURE_RO_COMPAT_SUPP OCFS2_FEATURE_RO_COMPAT_UNWRITTEN
96 97
97/* 98/*
@@ -128,10 +129,6 @@
128/* Support for data packed into inode blocks */ 129/* Support for data packed into inode blocks */
129#define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040 130#define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040
130 131
131/* Support for the extended slot map */
132#define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
133
134
135/* 132/*
136 * Support for alternate, userspace cluster stacks. If set, the superblock 133 * Support for alternate, userspace cluster stacks. If set, the superblock
137 * field s_cluster_info contains a tag for the alternate stack in use as 134 * field s_cluster_info contains a tag for the alternate stack in use as
@@ -143,6 +140,12 @@
143 */ 140 */
144#define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080 141#define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080
145 142
143/* Support for the extended slot map */
144#define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
145
146/* Support for extended attributes */
147#define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200
148
146/* 149/*
147 * backup superblock flag is used to indicate that this volume 150 * backup superblock flag is used to indicate that this volume
148 * has backup superblocks. 151 * has backup superblocks.
@@ -578,7 +581,11 @@ struct ocfs2_super_block {
578/*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Selected userspace 581/*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Selected userspace
579 stack. Only valid 582 stack. Only valid
580 with INCOMPAT flag. */ 583 with INCOMPAT flag. */
581/*B8*/ __le64 s_reserved2[17]; /* Fill out superblock */ 584/*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size
585 for this fs*/
586 __le16 s_reserved0;
587 __le32 s_reserved1;
588/*C0*/ __le64 s_reserved2[16]; /* Fill out superblock */
582/*140*/ 589/*140*/
583 590
584 /* 591 /*
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 3b04f5d2e896..c85e525950a9 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1437,7 +1437,8 @@ static int ocfs2_initialize_super(struct super_block *sb,
1437 1437
1438 osb->slot_num = OCFS2_INVALID_SLOT; 1438 osb->slot_num = OCFS2_INVALID_SLOT;
1439 1439
1440 osb->s_xattr_inline_size = OCFS2_MIN_XATTR_INLINE_SIZE; 1440 osb->s_xattr_inline_size = le16_to_cpu(
1441 di->id2.i_super.s_xattr_inline_size);
1441 1442
1442 osb->local_alloc_state = OCFS2_LA_UNUSED; 1443 osb->local_alloc_state = OCFS2_LA_UNUSED;
1443 osb->local_alloc_bh = NULL; 1444 osb->local_alloc_bh = NULL;
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 9ec7136b3ad7..090449f9263e 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -564,6 +564,9 @@ ssize_t ocfs2_listxattr(struct dentry *dentry,
564 struct ocfs2_dinode *di = NULL; 564 struct ocfs2_dinode *di = NULL;
565 struct ocfs2_inode_info *oi = OCFS2_I(dentry->d_inode); 565 struct ocfs2_inode_info *oi = OCFS2_I(dentry->d_inode);
566 566
567 if (!ocfs2_supports_xattr(OCFS2_SB(dentry->d_sb)))
568 return -EOPNOTSUPP;
569
567 if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL)) 570 if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL))
568 return ret; 571 return ret;
569 572
@@ -843,6 +846,9 @@ int ocfs2_xattr_get(struct inode *inode,
843 .not_found = -ENODATA, 846 .not_found = -ENODATA,
844 }; 847 };
845 848
849 if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
850 return -EOPNOTSUPP;
851
846 if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL)) 852 if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL))
847 ret = -ENODATA; 853 ret = -ENODATA;
848 854
@@ -1541,6 +1547,9 @@ int ocfs2_xattr_remove(struct inode *inode, struct buffer_head *di_bh)
1541 handle_t *handle; 1547 handle_t *handle;
1542 int ret; 1548 int ret;
1543 1549
1550 if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
1551 return 0;
1552
1544 if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL)) 1553 if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL))
1545 return 0; 1554 return 0;
1546 1555
@@ -1977,6 +1986,9 @@ int ocfs2_xattr_set(struct inode *inode,
1977 .not_found = -ENODATA, 1986 .not_found = -ENODATA,
1978 }; 1987 };
1979 1988
1989 if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
1990 return -EOPNOTSUPP;
1991
1980 ret = ocfs2_inode_lock(inode, &di_bh, 1); 1992 ret = ocfs2_inode_lock(inode, &di_bh, 1);
1981 if (ret < 0) { 1993 if (ret < 0) {
1982 mlog_errno(ret); 1994 mlog_errno(ret);