mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Fasheh <mfasheh@suse.com>
To: linux-kernel@vger.kernel.org
Cc: joel.becker@oracle.com, ocfs2-devel@oss.oracle.com,
	linux-fsdevel@vger.kernel.org, Tiger Yang <tiger.yang@oracle.com>,
	Mark Fasheh <mfasheh@suse.com>
Subject: [PATCH 12/39] ocfs2: reserve inline space for extended attribute
Date: Wed, 24 Sep 2008 15:00:53 -0700	[thread overview]
Message-ID: <1222293680-15451-13-git-send-email-mfasheh@suse.com> (raw)
In-Reply-To: <1222293680-15451-1-git-send-email-mfasheh@suse.com>

From: Tiger Yang <tiger.yang@oracle.com>

Add the structures and helper functions we want for handling inline extended
attributes. We also update the inline-data handlers so that they properly
function in the event that we have both inline data and inline attributes
sharing an inode block.

Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
 fs/ocfs2/alloc.c    |   22 ++++++++++++++++------
 fs/ocfs2/ocfs2.h    |    1 +
 fs/ocfs2/ocfs2_fs.h |   46 +++++++++++++++++++++++++++++++++++++++++++---
 fs/ocfs2/super.c    |    2 ++
 4 files changed, 62 insertions(+), 9 deletions(-)

diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 130988f..d175db1 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -6586,20 +6586,29 @@ out:
 	return ret;
 }
 
-static void ocfs2_zero_dinode_id2(struct inode *inode, struct ocfs2_dinode *di)
+static void ocfs2_zero_dinode_id2_with_xattr(struct inode *inode,
+					     struct ocfs2_dinode *di)
 {
 	unsigned int blocksize = 1 << inode->i_sb->s_blocksize_bits;
+	unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
 
-	memset(&di->id2, 0, blocksize - offsetof(struct ocfs2_dinode, id2));
+	if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
+		memset(&di->id2, 0, blocksize -
+				    offsetof(struct ocfs2_dinode, id2) -
+				    xattrsize);
+	else
+		memset(&di->id2, 0, blocksize -
+				    offsetof(struct ocfs2_dinode, id2));
 }
 
 void ocfs2_dinode_new_extent_list(struct inode *inode,
 				  struct ocfs2_dinode *di)
 {
-	ocfs2_zero_dinode_id2(inode, di);
+	ocfs2_zero_dinode_id2_with_xattr(inode, di);
 	di->id2.i_list.l_tree_depth = 0;
 	di->id2.i_list.l_next_free_rec = 0;
-	di->id2.i_list.l_count = cpu_to_le16(ocfs2_extent_recs_per_inode(inode->i_sb));
+	di->id2.i_list.l_count = cpu_to_le16(
+		ocfs2_extent_recs_per_inode_with_xattr(inode->i_sb, di));
 }
 
 void ocfs2_set_inode_data_inline(struct inode *inode, struct ocfs2_dinode *di)
@@ -6616,9 +6625,10 @@ void ocfs2_set_inode_data_inline(struct inode *inode, struct ocfs2_dinode *di)
 	 * We clear the entire i_data structure here so that all
 	 * fields can be properly initialized.
 	 */
-	ocfs2_zero_dinode_id2(inode, di);
+	ocfs2_zero_dinode_id2_with_xattr(inode, di);
 
-	idata->id_count = cpu_to_le16(ocfs2_max_inline_data(inode->i_sb));
+	idata->id_count = cpu_to_le16(
+			ocfs2_max_inline_data_with_xattr(inode->i_sb, di));
 }
 
 int ocfs2_convert_inline_data_to_extents(struct inode *inode,
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index 1282799..ce75ca3 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -245,6 +245,7 @@ struct ocfs2_super
 	int s_sectsize_bits;
 	int s_clustersize;
 	int s_clustersize_bits;
+	unsigned int s_xattr_inline_size;
 
 	atomic_t vol_state;
 	struct mutex recovery_lock;
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h
index 1b46505..1055ba0 100644
--- a/fs/ocfs2/ocfs2_fs.h
+++ b/fs/ocfs2/ocfs2_fs.h
@@ -300,6 +300,12 @@ struct ocfs2_new_group_input {
  */
 #define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE	8
 
+/*
+ * Inline extended attribute size (in bytes)
+ * The value chosen should be aligned to 16 byte boundaries.
+ */
+#define OCFS2_MIN_XATTR_INLINE_SIZE     256
+
 struct ocfs2_system_inode_info {
 	char	*si_name;
 	int	si_iflags;
@@ -622,7 +628,8 @@ struct ocfs2_dinode {
 					   belongs to */
 	__le16 i_suballoc_bit;		/* Bit offset in suballocator
 					   block group */
-/*10*/	__le32 i_reserved0;
+/*10*/	__le16 i_reserved0;
+	__le16 i_xattr_inline_size;
 	__le32 i_clusters;		/* Cluster count */
 	__le32 i_uid;			/* Owner UID */
 	__le32 i_gid;			/* Owning GID */
@@ -641,11 +648,12 @@ struct ocfs2_dinode {
 	__le32 i_atime_nsec;
 	__le32 i_ctime_nsec;
 	__le32 i_mtime_nsec;
-	__le32 i_attr;
+/*70*/	__le32 i_attr;
 	__le16 i_orphaned_slot;		/* Only valid when OCFS2_ORPHANED_FL
 					   was set in i_flags */
 	__le16 i_dyn_features;
-/*70*/	__le64 i_reserved2[8];
+	__le64 i_xattr_loc;
+/*80*/	__le64 i_reserved2[7];
 /*B8*/	union {
 		__le64 i_pad1;		/* Generic way to refer to this
 					   64bit union */
@@ -846,6 +854,20 @@ static inline int ocfs2_max_inline_data(struct super_block *sb)
 		offsetof(struct ocfs2_dinode, id2.i_data.id_data);
 }
 
+static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
+						   struct ocfs2_dinode *di)
+{
+	unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
+
+	if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
+		return sb->s_blocksize -
+			offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
+			xattrsize;
+	else
+		return sb->s_blocksize -
+			offsetof(struct ocfs2_dinode, id2.i_data.id_data);
+}
+
 static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
 {
 	int size;
@@ -856,6 +878,24 @@ static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
 	return size / sizeof(struct ocfs2_extent_rec);
 }
 
+static inline int ocfs2_extent_recs_per_inode_with_xattr(
+						struct super_block *sb,
+						struct ocfs2_dinode *di)
+{
+	int size;
+	unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
+
+	if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
+		size = sb->s_blocksize -
+			offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
+			xattrsize;
+	else
+		size = sb->s_blocksize -
+			offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
+
+	return size / sizeof(struct ocfs2_extent_rec);
+}
+
 static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
 {
 	int size;
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index e58a525..b08d143 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1424,6 +1424,8 @@ static int ocfs2_initialize_super(struct super_block *sb,
 
 	osb->slot_num = OCFS2_INVALID_SLOT;
 
+	osb->s_xattr_inline_size = OCFS2_MIN_XATTR_INLINE_SIZE;
+
 	osb->local_alloc_state = OCFS2_LA_UNUSED;
 	osb->local_alloc_bh = NULL;
 	INIT_DELAYED_WORK(&osb->la_enable_wq, ocfs2_la_enable_worker);
-- 
1.5.4.5


  parent reply	other threads:[~2008-09-24 22:04 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-24 22:00 [PATCH 0/39] Ocfs2 updates for 2.6.28 Mark Fasheh
2008-09-24 22:00 ` [PATCH 01/39] ocfs2: POSIX file locks support Mark Fasheh
2008-10-02  6:11   ` Andrew Morton
2008-10-07 20:09     ` Mark Fasheh
2008-09-24 22:00 ` [PATCH 02/39] ocfs2: Track local alloc bits internally Mark Fasheh
2008-09-24 22:00 ` [PATCH 03/39] ocfs2: throttle back local alloc when low on disk space Mark Fasheh
2008-10-02  6:11   ` Andrew Morton
2008-09-24 22:00 ` [PATCH 04/39] ocfs2: track local alloc state via debugfs Mark Fasheh
2008-10-02  6:11   ` Andrew Morton
2008-10-07 20:10     ` Mark Fasheh
2008-09-24 22:00 ` [PATCH 05/39] ocfs2: Modify ocfs2_num_free_extents for future xattr usage Mark Fasheh
2008-09-24 22:00 ` [PATCH 06/39] ocfs2: Use ocfs2_extent_list instead of ocfs2_dinode Mark Fasheh
2008-09-24 22:00 ` [PATCH 07/39] ocfs2: Abstract ocfs2_extent_tree in b-tree operations Mark Fasheh
2008-09-24 22:00 ` [PATCH 08/39] ocfs2: Make high level btree extend code generic Mark Fasheh
2008-09-24 22:00 ` [PATCH 09/39] ocfs2: Add the basic xattr disk layout in ocfs2_fs.h Mark Fasheh
2008-09-24 22:00 ` [PATCH 10/39] ocfs2: Add helper function in uptodate.c for removing xattr clusters Mark Fasheh
2008-10-02  6:11   ` Andrew Morton
2008-10-07 20:18     ` Mark Fasheh
2008-09-24 22:00 ` [PATCH 11/39] ocfs2: Add extent tree operation for xattr value btrees Mark Fasheh
2008-10-02  6:12   ` Andrew Morton
2008-10-07 20:19     ` Mark Fasheh
2008-10-02  6:12   ` Andrew Morton
2008-10-07 21:19     ` Mark Fasheh
2008-09-24 22:00 ` Mark Fasheh [this message]
2008-09-24 22:00 ` [PATCH 13/39] ocfs2: Add extended attribute support Mark Fasheh
2008-10-02  6:12   ` Andrew Morton
2008-10-07 20:22     ` Mark Fasheh
2008-10-02  8:16   ` [Ocfs2-devel] " Christoph Hellwig
2008-10-07 22:08     ` Mark Fasheh
2008-10-08  1:56       ` Tiger Yang
2008-10-08 13:16         ` Christoph Hellwig
2008-10-08 13:34         ` Christoph Hellwig
2008-10-08 14:04           ` Tao Ma
2008-10-09  0:38             ` Mark Fasheh
2008-10-08 13:22       ` Christoph Hellwig
2008-09-24 22:00 ` [PATCH 14/39] ocfs2: Add xattr index tree operations Mark Fasheh
2008-09-24 22:00 ` [PATCH 15/39] ocfs2: Add xattr bucket iteration for large numbers of EAs Mark Fasheh
2008-09-24 22:00 ` [PATCH 16/39] ocfs2: Add xattr lookup code xattr btrees Mark Fasheh
2008-09-24 22:00 ` [PATCH 17/39] ocfs2: Optionally limit extent size in ocfs2_insert_extent() Mark Fasheh
2008-09-24 22:00 ` [PATCH 18/39] ocfs2: Enable xattr set in index btree Mark Fasheh
2008-09-24 22:01 ` [PATCH 19/39] ocfs2: Delete all xattr buckets during inode removal Mark Fasheh
2008-09-24 22:01 ` [PATCH 20/39] ocfs2: Add incompatible flag for extended attribute Mark Fasheh
2008-09-24 22:01 ` [PATCH 21/39] ocfs2: fix printk format warnings Mark Fasheh
2008-09-24 22:01 ` [PATCH 22/39] ocfs2: Prefix the extent tree operations structure Mark Fasheh
2008-09-24 22:01 ` [PATCH 23/39] ocfs2: Prefix the ocfs2_extent_tree structure Mark Fasheh
2008-09-24 22:01 ` [PATCH 24/39] ocfs2: Make ocfs2_extent_tree get/put instead of alloc Mark Fasheh
2008-09-24 22:01 ` [PATCH 25/39] ocfs2: Make 'private' into 'object' on ocfs2_extent_tree Mark Fasheh
2008-09-24 22:01 ` [PATCH 26/39] ocfs2: Provide the get_root_el() method to ocfs2_extent_tree_operations Mark Fasheh
2008-09-24 22:01 ` [PATCH 27/39] ocfs2: Use struct ocfs2_extent_tree in ocfs2_num_free_extents() Mark Fasheh
2008-09-24 22:01 ` [PATCH 28/39] ocfs2: Determine an extent tree's max_leaf_clusters in an et_op Mark Fasheh
2008-09-24 22:01 ` [PATCH 29/39] ocfs2: Create specific get_extent_tree functions Mark Fasheh
2008-09-24 22:01 ` [PATCH 30/39] ocfs2: Add an insertion check to ocfs2_extent_tree_operations Mark Fasheh
2008-09-24 22:01 ` [PATCH 31/39] ocfs2: Make ocfs2_extent_tree the first-class representation of a tree Mark Fasheh
2008-09-24 22:01 ` [PATCH 32/39] ocfs2: Comment struct ocfs2_extent_tree_operations Mark Fasheh
2008-09-24 22:01 ` [PATCH 33/39] ocfs2: Change ocfs2_get_*_extent_tree() to ocfs2_init_*_extent_tree() Mark Fasheh
2008-09-24 22:01 ` [PATCH 34/39] ocfs2: bug-fix for journal extend in xattr Mark Fasheh
2008-09-24 22:01 ` [PATCH 35/39] ocfs2: Resolve deadlock in ocfs2_xattr_free_block Mark Fasheh
2008-09-24 22:01 ` [PATCH 36/39] ocfs2: Limit inode allocation to 32bits Mark Fasheh
2008-09-24 22:01 ` [PATCH 37/39] ocfs2: Add the 'inode64' mount option Mark Fasheh
2008-09-24 22:01 ` [PATCH 38/39] ocfs2: Switch over to JBD2 Mark Fasheh
2008-09-24 22:01 ` [PATCH 39/39] ocfs2: Add xattr mount option in ocfs2_show_options() Mark Fasheh
2008-09-28  5:16 ` [PATCH 0/39] Ocfs2 updates for 2.6.28 Tao Ma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1222293680-15451-13-git-send-email-mfasheh@suse.com \
    --to=mfasheh@suse.com \
    --cc=joel.becker@oracle.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ocfs2-devel@oss.oracle.com \
    --cc=tiger.yang@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®