All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: linux-fsdevel@vger.kernel.org
Cc: linux-ext4@vger.kernel.org, Dave Chinner <david@fromorbit.com>,
	xfs@oss.sgi.com, cluster-devel@redhat.com,
	Steven Whitehouse <swhiteho@redhat.com>,
	Mark Fasheh <mfasheh@suse.com>, Joel Becker <jlbec@evilplan.org>,
	ocfs2-devel@oss.oracle.com, reiserfs-devel@vger.kernel.org,
	Jeff Mahoney <jeffm@suse.de>, Dave Kleikamp <shaggy@kernel.org>,
	jfs-discussion@lists.sourceforge.net, tytso@mit.edu,
	viro@zeniv.linux.org.uk, Jan Kara <jack@suse.cz>
Subject: [PATCH 04/12] fs: Generic infrastructure for optional inode fields
Date: Fri, 10 Oct 2014 16:55:02 +0200	[thread overview]
Message-ID: <1412952910-7142-5-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1412952910-7142-1-git-send-email-jack@suse.cz>

There are parts of struct inode which are used only by a few filesystems
(e.g. i_dquot pointers, i_mapping->private_list, ...). Thus all the
other filesystems are just wasting memory with these fields. On the
other hand it isn't simple to just move these fields to filesystem
specific part of inode because there is generic code which needs to peek
into the fields and it is cumbersome to provide helpers into which fs
has to stuff the field it is storing elsewhere.

We create a simple infrastructure which allows for optional inode fields
stored in the fs-specific part of the inode. Accessing these fields has
a slightly worse performance as we have to lookup their offset in the
offset table stored in the superblock but in most cases this is
acceptable. Notably, this offset-table mechanism is faster than having
fs-specific hook functions which would need to be called to provide
pointers to desired fields.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 include/linux/fs.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 94187721ad41..f2468786a36b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -615,6 +615,11 @@ struct inode {
 	void			*i_private; /* fs or device private pointer */
 };
 
+/* Optional inode fields (stored in filesystems inode if the fs needs them) */
+enum inode_fields {
+	IF_FIELD_NR	/* Number of optional inode fields */
+};
+
 static inline int inode_unhashed(struct inode *inode)
 {
 	return hlist_unhashed(&inode->i_hash);
@@ -1236,6 +1241,11 @@ struct super_block {
 	void 			*s_fs_info;	/* Filesystem private info */
 	unsigned int		s_max_links;
 	fmode_t			s_mode;
+	/*
+	 * We could have here just a pointer to the offsets array but this
+	 * way we save one dereference when looking up field offsets
+	 */
+	int			s_inode_fields[IF_FIELD_NR];
 
 	/* Granularity of c/m/atime in ns.
 	   Cannot be worse than a second */
@@ -1286,6 +1296,24 @@ struct super_block {
 	struct rcu_head		rcu;
 };
 
+static inline void *inode_field(const struct inode *inode,
+				enum inode_fields field)
+{
+	int offset;
+
+	BUG_ON(field >= IF_FIELD_NR);
+	offset = inode->i_sb->s_inode_fields[field];
+	if (!offset)	/* Field not present? */
+		return NULL;
+	return ((char *)inode) + offset;
+}
+
+static inline void sb_init_inode_fields(struct super_block *sb,
+					const int *fields)
+{
+	memcpy(sb->s_inode_fields, fields, sizeof(int) * IF_FIELD_NR);
+}
+
 extern struct timespec current_fs_time(struct super_block *sb);
 
 /*
-- 
1.8.1.4


WARNING: multiple messages have this Message-ID (diff)
From: Jan Kara <jack@suse.cz>
To: linux-fsdevel@vger.kernel.org
Cc: Dave Kleikamp <shaggy@kernel.org>,
	jfs-discussion@lists.sourceforge.net, tytso@mit.edu,
	Jeff Mahoney <jeffm@suse.de>, Mark Fasheh <mfasheh@suse.com>,
	reiserfs-devel@vger.kernel.org, xfs@oss.sgi.com,
	cluster-devel@redhat.com, Joel Becker <jlbec@evilplan.org>,
	Jan Kara <jack@suse.cz>,
	linux-ext4@vger.kernel.org,
	Steven Whitehouse <swhiteho@redhat.com>,
	ocfs2-devel@oss.oracle.com, viro@zeniv.linux.org.uk
Subject: [PATCH 04/12] fs: Generic infrastructure for optional inode fields
Date: Fri, 10 Oct 2014 16:55:02 +0200	[thread overview]
Message-ID: <1412952910-7142-5-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1412952910-7142-1-git-send-email-jack@suse.cz>

There are parts of struct inode which are used only by a few filesystems
(e.g. i_dquot pointers, i_mapping->private_list, ...). Thus all the
other filesystems are just wasting memory with these fields. On the
other hand it isn't simple to just move these fields to filesystem
specific part of inode because there is generic code which needs to peek
into the fields and it is cumbersome to provide helpers into which fs
has to stuff the field it is storing elsewhere.

We create a simple infrastructure which allows for optional inode fields
stored in the fs-specific part of the inode. Accessing these fields has
a slightly worse performance as we have to lookup their offset in the
offset table stored in the superblock but in most cases this is
acceptable. Notably, this offset-table mechanism is faster than having
fs-specific hook functions which would need to be called to provide
pointers to desired fields.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 include/linux/fs.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 94187721ad41..f2468786a36b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -615,6 +615,11 @@ struct inode {
 	void			*i_private; /* fs or device private pointer */
 };
 
+/* Optional inode fields (stored in filesystems inode if the fs needs them) */
+enum inode_fields {
+	IF_FIELD_NR	/* Number of optional inode fields */
+};
+
 static inline int inode_unhashed(struct inode *inode)
 {
 	return hlist_unhashed(&inode->i_hash);
@@ -1236,6 +1241,11 @@ struct super_block {
 	void 			*s_fs_info;	/* Filesystem private info */
 	unsigned int		s_max_links;
 	fmode_t			s_mode;
+	/*
+	 * We could have here just a pointer to the offsets array but this
+	 * way we save one dereference when looking up field offsets
+	 */
+	int			s_inode_fields[IF_FIELD_NR];
 
 	/* Granularity of c/m/atime in ns.
 	   Cannot be worse than a second */
@@ -1286,6 +1296,24 @@ struct super_block {
 	struct rcu_head		rcu;
 };
 
+static inline void *inode_field(const struct inode *inode,
+				enum inode_fields field)
+{
+	int offset;
+
+	BUG_ON(field >= IF_FIELD_NR);
+	offset = inode->i_sb->s_inode_fields[field];
+	if (!offset)	/* Field not present? */
+		return NULL;
+	return ((char *)inode) + offset;
+}
+
+static inline void sb_init_inode_fields(struct super_block *sb,
+					const int *fields)
+{
+	memcpy(sb->s_inode_fields, fields, sizeof(int) * IF_FIELD_NR);
+}
+
 extern struct timespec current_fs_time(struct super_block *sb);
 
 /*
-- 
1.8.1.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

WARNING: multiple messages have this Message-ID (diff)
From: Jan Kara <jack@suse.cz>
To: linux-fsdevel@vger.kernel.org
Cc: linux-ext4@vger.kernel.org, Dave Chinner <david@fromorbit.com>,
	xfs@oss.sgi.com, cluster-devel@redhat.com,
	Steven Whitehouse <swhiteho@redhat.com>,
	Mark Fasheh <mfasheh@suse.com>, Joel Becker <jlbec@evilplan.org>,
	ocfs2-devel@oss.oracle.com, reiserfs-devel@vger.kernel.org,
	Jeff Mahoney <jeffm@suse.de>, Dave Kleikamp <shaggy@kernel.org>,
	jfs-discussion@lists.sourceforge.net, tytso@mit.edu,
	viro@zeniv.linux.org.uk, Jan Kara <jack@suse.cz>
Subject: [Ocfs2-devel] [PATCH 04/12] fs: Generic infrastructure for optional inode fields
Date: Fri, 10 Oct 2014 16:55:02 +0200	[thread overview]
Message-ID: <1412952910-7142-5-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1412952910-7142-1-git-send-email-jack@suse.cz>

There are parts of struct inode which are used only by a few filesystems
(e.g. i_dquot pointers, i_mapping->private_list, ...). Thus all the
other filesystems are just wasting memory with these fields. On the
other hand it isn't simple to just move these fields to filesystem
specific part of inode because there is generic code which needs to peek
into the fields and it is cumbersome to provide helpers into which fs
has to stuff the field it is storing elsewhere.

We create a simple infrastructure which allows for optional inode fields
stored in the fs-specific part of the inode. Accessing these fields has
a slightly worse performance as we have to lookup their offset in the
offset table stored in the superblock but in most cases this is
acceptable. Notably, this offset-table mechanism is faster than having
fs-specific hook functions which would need to be called to provide
pointers to desired fields.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 include/linux/fs.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 94187721ad41..f2468786a36b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -615,6 +615,11 @@ struct inode {
 	void			*i_private; /* fs or device private pointer */
 };
 
+/* Optional inode fields (stored in filesystems inode if the fs needs them) */
+enum inode_fields {
+	IF_FIELD_NR	/* Number of optional inode fields */
+};
+
 static inline int inode_unhashed(struct inode *inode)
 {
 	return hlist_unhashed(&inode->i_hash);
@@ -1236,6 +1241,11 @@ struct super_block {
 	void 			*s_fs_info;	/* Filesystem private info */
 	unsigned int		s_max_links;
 	fmode_t			s_mode;
+	/*
+	 * We could have here just a pointer to the offsets array but this
+	 * way we save one dereference when looking up field offsets
+	 */
+	int			s_inode_fields[IF_FIELD_NR];
 
 	/* Granularity of c/m/atime in ns.
 	   Cannot be worse than a second */
@@ -1286,6 +1296,24 @@ struct super_block {
 	struct rcu_head		rcu;
 };
 
+static inline void *inode_field(const struct inode *inode,
+				enum inode_fields field)
+{
+	int offset;
+
+	BUG_ON(field >= IF_FIELD_NR);
+	offset = inode->i_sb->s_inode_fields[field];
+	if (!offset)	/* Field not present? */
+		return NULL;
+	return ((char *)inode) + offset;
+}
+
+static inline void sb_init_inode_fields(struct super_block *sb,
+					const int *fields)
+{
+	memcpy(sb->s_inode_fields, fields, sizeof(int) * IF_FIELD_NR);
+}
+
 extern struct timespec current_fs_time(struct super_block *sb);
 
 /*
-- 
1.8.1.4

WARNING: multiple messages have this Message-ID (diff)
From: Jan Kara <jack@suse.cz>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 04/12] fs: Generic infrastructure for optional inode fields
Date: Fri, 10 Oct 2014 16:55:02 +0200	[thread overview]
Message-ID: <1412952910-7142-5-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1412952910-7142-1-git-send-email-jack@suse.cz>

There are parts of struct inode which are used only by a few filesystems
(e.g. i_dquot pointers, i_mapping->private_list, ...). Thus all the
other filesystems are just wasting memory with these fields. On the
other hand it isn't simple to just move these fields to filesystem
specific part of inode because there is generic code which needs to peek
into the fields and it is cumbersome to provide helpers into which fs
has to stuff the field it is storing elsewhere.

We create a simple infrastructure which allows for optional inode fields
stored in the fs-specific part of the inode. Accessing these fields has
a slightly worse performance as we have to lookup their offset in the
offset table stored in the superblock but in most cases this is
acceptable. Notably, this offset-table mechanism is faster than having
fs-specific hook functions which would need to be called to provide
pointers to desired fields.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 include/linux/fs.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 94187721ad41..f2468786a36b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -615,6 +615,11 @@ struct inode {
 	void			*i_private; /* fs or device private pointer */
 };
 
+/* Optional inode fields (stored in filesystems inode if the fs needs them) */
+enum inode_fields {
+	IF_FIELD_NR	/* Number of optional inode fields */
+};
+
 static inline int inode_unhashed(struct inode *inode)
 {
 	return hlist_unhashed(&inode->i_hash);
@@ -1236,6 +1241,11 @@ struct super_block {
 	void 			*s_fs_info;	/* Filesystem private info */
 	unsigned int		s_max_links;
 	fmode_t			s_mode;
+	/*
+	 * We could have here just a pointer to the offsets array but this
+	 * way we save one dereference when looking up field offsets
+	 */
+	int			s_inode_fields[IF_FIELD_NR];
 
 	/* Granularity of c/m/atime in ns.
 	   Cannot be worse than a second */
@@ -1286,6 +1296,24 @@ struct super_block {
 	struct rcu_head		rcu;
 };
 
+static inline void *inode_field(const struct inode *inode,
+				enum inode_fields field)
+{
+	int offset;
+
+	BUG_ON(field >= IF_FIELD_NR);
+	offset = inode->i_sb->s_inode_fields[field];
+	if (!offset)	/* Field not present? */
+		return NULL;
+	return ((char *)inode) + offset;
+}
+
+static inline void sb_init_inode_fields(struct super_block *sb,
+					const int *fields)
+{
+	memcpy(sb->s_inode_fields, fields, sizeof(int) * IF_FIELD_NR);
+}
+
 extern struct timespec current_fs_time(struct super_block *sb);
 
 /*
-- 
1.8.1.4



  parent reply	other threads:[~2014-10-10 14:55 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-10 14:54 [PATCH 0/12 v2] Moving i_dquot out of struct inode Jan Kara
2014-10-10 14:54 ` [Cluster-devel] " Jan Kara
2014-10-10 14:54 ` [Ocfs2-devel] " Jan Kara
2014-10-10 14:54 ` Jan Kara
2014-10-10 14:54 ` [PATCH 01/12] quota: Allow each filesystem to specify which quota types it supports Jan Kara
2014-10-10 14:54   ` [Cluster-devel] " Jan Kara
2014-10-10 14:54   ` [Ocfs2-devel] " Jan Kara
2014-10-10 14:54   ` Jan Kara
2014-10-10 15:26   ` Dave Kleikamp
2014-10-10 15:26     ` [Cluster-devel] " Dave Kleikamp
2014-10-10 15:26     ` [Ocfs2-devel] " Dave Kleikamp
2014-10-10 15:26     ` Dave Kleikamp
2014-10-10 15:37     ` Jan Kara
2014-10-10 15:37       ` [Cluster-devel] " Jan Kara
2014-10-10 15:37       ` [Ocfs2-devel] " Jan Kara
2014-10-10 15:37       ` Jan Kara
2014-10-10 14:55 ` [PATCH 02/12] gfs2: Set allowed quota types Jan Kara
2014-10-10 14:55   ` [Cluster-devel] " Jan Kara
2014-10-10 14:55   ` [Ocfs2-devel] " Jan Kara
2014-10-10 14:55   ` Jan Kara
2014-10-10 14:55 ` [PATCH 03/12] xfs: " Jan Kara
2014-10-10 14:55   ` [Cluster-devel] " Jan Kara
2014-10-10 14:55   ` [Ocfs2-devel] " Jan Kara
2014-10-10 14:55   ` Jan Kara
2014-10-10 14:55 ` Jan Kara [this message]
2014-10-10 14:55   ` [Cluster-devel] [PATCH 04/12] fs: Generic infrastructure for optional inode fields Jan Kara
2014-10-10 14:55   ` [Ocfs2-devel] " Jan Kara
2014-10-10 14:55   ` Jan Kara
2014-10-10 14:55 ` [PATCH 05/12] quota: Use optional inode field for i_dquot pointers Jan Kara
2014-10-10 14:55   ` [Cluster-devel] " Jan Kara
2014-10-10 14:55   ` [Ocfs2-devel] " Jan Kara
2014-10-10 14:55   ` Jan Kara
2014-10-10 14:55 ` [PATCH 06/12] ext2: Convert to private i_dquot field Jan Kara
2014-10-10 14:55   ` [Cluster-devel] " Jan Kara
2014-10-10 14:55   ` [Ocfs2-devel] " Jan Kara
2014-10-10 14:55   ` Jan Kara
2014-10-10 14:55 ` [PATCH 07/12] ext3: " Jan Kara
2014-10-10 14:55   ` [Cluster-devel] " Jan Kara
2014-10-10 14:55   ` [Ocfs2-devel] " Jan Kara
2014-10-10 14:55 ` [PATCH 08/12] ext4: " Jan Kara
2014-10-10 14:55   ` [Cluster-devel] " Jan Kara
2014-10-10 14:55   ` [Ocfs2-devel] " Jan Kara
2014-10-10 14:55   ` Jan Kara
2014-10-10 14:55 ` [PATCH 09/12] ocfs2: " Jan Kara
2014-10-10 14:55   ` [Cluster-devel] " Jan Kara
2014-10-10 14:55   ` [Ocfs2-devel] " Jan Kara
2014-10-10 14:55   ` Jan Kara
2014-10-10 14:55 ` [PATCH 10/12] reiserfs: " Jan Kara
2014-10-10 14:55   ` [Cluster-devel] " Jan Kara
2014-10-10 14:55   ` [Ocfs2-devel] " Jan Kara
2014-10-10 14:55   ` Jan Kara
2014-10-10 14:55 ` [PATCH 11/12] jfs: " Jan Kara
2014-10-10 14:55   ` [Cluster-devel] " Jan Kara
2014-10-10 14:55   ` [Ocfs2-devel] " Jan Kara
2014-10-10 14:55   ` Jan Kara
2014-10-10 15:33   ` Dave Kleikamp
2014-10-10 15:33     ` [Cluster-devel] " Dave Kleikamp
2014-10-10 15:33     ` [Ocfs2-devel] " Dave Kleikamp
2014-10-10 15:33     ` Dave Kleikamp
2014-10-10 15:40     ` Jan Kara
2014-10-10 15:40       ` [Cluster-devel] " Jan Kara
2014-10-10 15:40       ` [Ocfs2-devel] " Jan Kara
2014-10-10 15:40       ` Jan Kara
2014-10-10 15:43       ` Dave Kleikamp
2014-10-10 15:43         ` [Cluster-devel] " Dave Kleikamp
2014-10-10 15:43         ` [Ocfs2-devel] " Dave Kleikamp
2014-10-10 15:43         ` Dave Kleikamp
2014-10-10 14:55 ` [PATCH 12/12] vfs: Remove i_dquot field from inode Jan Kara
2014-10-10 14:55   ` [Cluster-devel] " Jan Kara
2014-10-10 14:55   ` [Ocfs2-devel] " Jan Kara
2014-10-10 14:55   ` Jan Kara
2014-10-11 13:34 ` [PATCH 0/12 v2] Moving i_dquot out of struct inode Christoph Hellwig
2014-10-11 13:34   ` [Cluster-devel] " Christoph Hellwig
2014-10-11 13:34   ` [Ocfs2-devel] " Christoph Hellwig
2014-10-11 13:34   ` Christoph Hellwig
2014-10-12 18:53   ` Al Viro
2014-10-12 18:53     ` [Cluster-devel] " Al Viro
2014-10-12 18:53     ` [Ocfs2-devel] " Al Viro
2014-10-12 18:53     ` Al Viro
2014-10-17 19:24   ` Jan Kara
2014-10-17 19:24     ` [Cluster-devel] " Jan Kara
2014-10-17 19:24     ` [Ocfs2-devel] " Jan Kara
2014-10-17 19:24     ` Jan Kara
2014-10-18 15:17     ` Christoph Hellwig
2014-10-18 15:17       ` [Cluster-devel] " Christoph Hellwig
2014-10-18 15:17       ` [Ocfs2-devel] " Christoph Hellwig
2014-10-18 15:17       ` Christoph Hellwig
2014-10-18 19:26       ` Jan Kara
2014-10-18 19:26         ` [Cluster-devel] " Jan Kara
2014-10-18 19:26         ` [Ocfs2-devel] " Jan Kara
2014-10-18 19:26         ` Jan Kara
2014-10-19 14:16         ` Christoph Hellwig
2014-10-19 14:16           ` [Cluster-devel] " Christoph Hellwig
2014-10-19 14:16           ` [Ocfs2-devel] " Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2014-10-01 19:31 [PATCH 0/12 RFC] " Jan Kara
2014-10-01 19:31 ` [PATCH 04/12] fs: Generic infrastructure for optional inode fields Jan Kara
2014-10-01 21:05   ` Andreas Dilger
2014-10-01 21:05     ` Andreas Dilger
2014-10-08  8:45     ` Jan Kara

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=1412952910-7142-5-git-send-email-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=cluster-devel@redhat.com \
    --cc=david@fromorbit.com \
    --cc=jeffm@suse.de \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=jlbec@evilplan.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mfasheh@suse.com \
    --cc=ocfs2-devel@oss.oracle.com \
    --cc=reiserfs-devel@vger.kernel.org \
    --cc=shaggy@kernel.org \
    --cc=swhiteho@redhat.com \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xfs@oss.sgi.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 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.