From: Mark Fasheh <mfasheh@suse.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
ocfs2-devel@oss.oracle.com, Tao Ma <tao.ma@oracle.com>
Subject: Re: [Ocfs2-devel] [PATCH 13/39] ocfs2: Add extended attribute support
Date: Tue, 7 Oct 2008 15:08:11 -0700 [thread overview]
Message-ID: <20081007220811.GG26373@wotan.suse.de> (raw)
In-Reply-To: <20081002081644.GB24717@lst.de>
On Thu, Oct 02, 2008 at 10:16:44AM +0200, Christoph Hellwig wrote:
> On Wed, Sep 24, 2008 at 03:00:54PM -0700, Mark Fasheh wrote:
> > xattr.o \
> > + xattr_user.o \
> > + xattr_trusted.o
>
> Please don't split this up, it's always been a really stupid idea in
> extN. The only difference between secure, trusted and user attrs is
> that they go into a different namespace bit (and have different
> permission checking, but that's handled in the VFS). I have some
> upcoming patches to store a fs private flag in struct xattr_handler
> so that even those flags wrappers can go away, and each of the
> namespaces will just be five lines of code for the xattr_handler
> declaration.
Ok. The following patch (in ocfs2.git now) removes those two files, and puts
the code for user and trusted xattrs at the bottom of xattr.c. Is that
mainly what you were getting at here?
> > +static inline struct xattr_handler *ocfs2_xattr_handler(int name_index)
> > +{
> > + struct xattr_handler *handler = NULL;
> > +
> > + if (name_index > 0 && name_index < OCFS2_XATTR_MAX)
> > + handler = ocfs2_xattr_handler_map[name_index];
> > +
> > + return handler;
> > +}
>
> You seem to need the handler mostly for getting back to the prefix
> from the handler. This is a pretty clear indicator that you don't
> want to use the xattr_handler splitting but deal with the whole
> attr name. Take a look at the btrfs code after my recent xattr changes
> on how to handle this more nicely.
Tao, Can you look into this?
> > +
> > +static inline u32 ocfs2_xattr_name_hash(struct inode *inode,
> > + char *prefix,
> > + int prefix_len,
> > + char *name,
> > + int name_len)
>
> And I think there's far too much inlining going on in here..
Yep, I went ahead and un-inlined that function.
Thanks for the review,
--Mark
--
Mark Fasheh
From: Mark Fasheh <mfasheh@suse.com>
ocfs2: Move trusted and user attribute support into xattr.c
Per Christoph Hellwig's suggestion - don't split these up. It's not like we
gained much by having the two tiny files around.
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
fs/ocfs2/Makefile | 4 +-
fs/ocfs2/xattr.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++
fs/ocfs2/xattr_trusted.c | 82 ----------------------------------
fs/ocfs2/xattr_user.c | 94 ---------------------------------------
4 files changed, 111 insertions(+), 179 deletions(-)
delete mode 100644 fs/ocfs2/xattr_trusted.c
delete mode 100644 fs/ocfs2/xattr_user.c
diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile
index 21323da..589dcdf 100644
--- a/fs/ocfs2/Makefile
+++ b/fs/ocfs2/Makefile
@@ -35,9 +35,7 @@ ocfs2-objs := \
sysfile.o \
uptodate.o \
ver.o \
- xattr.o \
- xattr_user.o \
- xattr_trusted.o
+ xattr.o
ocfs2_stackglue-objs := stackglue.o
ocfs2_stack_o2cb-objs := stack_o2cb.o
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index e21a1a8..0f556b0 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -37,6 +37,9 @@
#include <linux/writeback.h>
#include <linux/falloc.h>
#include <linux/sort.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/string.h>
#define MLOG_MASK_PREFIX ML_XATTR
#include <cluster/masklog.h>
@@ -4740,3 +4743,110 @@ static int ocfs2_delete_xattr_index_block(struct inode *inode,
out:
return ret;
}
+
+/*
+ * 'trusted' attributes support
+ */
+
+#define XATTR_TRUSTED_PREFIX "trusted."
+
+static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list,
+ size_t list_size, const char *name,
+ size_t name_len)
+{
+ const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX) - 1;
+ const size_t total_len = prefix_len + name_len + 1;
+
+ if (list && total_len <= list_size) {
+ memcpy(list, XATTR_TRUSTED_PREFIX, prefix_len);
+ memcpy(list + prefix_len, name, name_len);
+ list[prefix_len + name_len] = '\0';
+ }
+ return total_len;
+}
+
+static int ocfs2_xattr_trusted_get(struct inode *inode, const char *name,
+ void *buffer, size_t size)
+{
+ if (strcmp(name, "") == 0)
+ return -EINVAL;
+ return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, name,
+ buffer, size);
+}
+
+static int ocfs2_xattr_trusted_set(struct inode *inode, const char *name,
+ const void *value, size_t size, int flags)
+{
+ if (strcmp(name, "") == 0)
+ return -EINVAL;
+
+ return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED, name, value,
+ size, flags);
+}
+
+struct xattr_handler ocfs2_xattr_trusted_handler = {
+ .prefix = XATTR_TRUSTED_PREFIX,
+ .list = ocfs2_xattr_trusted_list,
+ .get = ocfs2_xattr_trusted_get,
+ .set = ocfs2_xattr_trusted_set,
+};
+
+
+/*
+ * 'user' attributes support
+ */
+
+#define XATTR_USER_PREFIX "user."
+
+static size_t ocfs2_xattr_user_list(struct inode *inode, char *list,
+ size_t list_size, const char *name,
+ size_t name_len)
+{
+ const size_t prefix_len = sizeof(XATTR_USER_PREFIX) - 1;
+ const size_t total_len = prefix_len + name_len + 1;
+ struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+
+ if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
+ return 0;
+
+ if (list && total_len <= list_size) {
+ memcpy(list, XATTR_USER_PREFIX, prefix_len);
+ memcpy(list + prefix_len, name, name_len);
+ list[prefix_len + name_len] = '\0';
+ }
+ return total_len;
+}
+
+static int ocfs2_xattr_user_get(struct inode *inode, const char *name,
+ void *buffer, size_t size)
+{
+ struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+
+ if (strcmp(name, "") == 0)
+ return -EINVAL;
+ if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
+ return -EOPNOTSUPP;
+ return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name,
+ buffer, size);
+}
+
+static int ocfs2_xattr_user_set(struct inode *inode, const char *name,
+ const void *value, size_t size, int flags)
+{
+ struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+
+ if (strcmp(name, "") == 0)
+ return -EINVAL;
+ if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
+ return -EOPNOTSUPP;
+
+ return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value,
+ size, flags);
+}
+
+struct xattr_handler ocfs2_xattr_user_handler = {
+ .prefix = XATTR_USER_PREFIX,
+ .list = ocfs2_xattr_user_list,
+ .get = ocfs2_xattr_user_get,
+ .set = ocfs2_xattr_user_set,
+};
diff --git a/fs/ocfs2/xattr_trusted.c b/fs/ocfs2/xattr_trusted.c
deleted file mode 100644
index 4c589c4..0000000
--- a/fs/ocfs2/xattr_trusted.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * xattr_trusted.c
- *
- * Copyright (C) 2008 Oracle. All rights reserved.
- *
- * CREDITS:
- * Lots of code in this file is taken from ext3.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/string.h>
-
-#define MLOG_MASK_PREFIX ML_INODE
-#include <cluster/masklog.h>
-
-#include "ocfs2.h"
-#include "alloc.h"
-#include "dlmglue.h"
-#include "file.h"
-#include "ocfs2_fs.h"
-#include "xattr.h"
-
-#define XATTR_TRUSTED_PREFIX "trusted."
-
-static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list,
- size_t list_size, const char *name,
- size_t name_len)
-{
- const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX) - 1;
- const size_t total_len = prefix_len + name_len + 1;
-
- if (list && total_len <= list_size) {
- memcpy(list, XATTR_TRUSTED_PREFIX, prefix_len);
- memcpy(list + prefix_len, name, name_len);
- list[prefix_len + name_len] = '\0';
- }
- return total_len;
-}
-
-static int ocfs2_xattr_trusted_get(struct inode *inode, const char *name,
- void *buffer, size_t size)
-{
- if (strcmp(name, "") == 0)
- return -EINVAL;
- return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, name,
- buffer, size);
-}
-
-static int ocfs2_xattr_trusted_set(struct inode *inode, const char *name,
- const void *value, size_t size, int flags)
-{
- if (strcmp(name, "") == 0)
- return -EINVAL;
-
- return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED, name, value,
- size, flags);
-}
-
-struct xattr_handler ocfs2_xattr_trusted_handler = {
- .prefix = XATTR_TRUSTED_PREFIX,
- .list = ocfs2_xattr_trusted_list,
- .get = ocfs2_xattr_trusted_get,
- .set = ocfs2_xattr_trusted_set,
-};
diff --git a/fs/ocfs2/xattr_user.c b/fs/ocfs2/xattr_user.c
deleted file mode 100644
index 93ba716..0000000
--- a/fs/ocfs2/xattr_user.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * xattr_user.c
- *
- * Copyright (C) 2008 Oracle. All rights reserved.
- *
- * CREDITS:
- * Lots of code in this file is taken from ext3.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/string.h>
-
-#define MLOG_MASK_PREFIX ML_INODE
-#include <cluster/masklog.h>
-
-#include "ocfs2.h"
-#include "alloc.h"
-#include "dlmglue.h"
-#include "file.h"
-#include "ocfs2_fs.h"
-#include "xattr.h"
-
-#define XATTR_USER_PREFIX "user."
-
-static size_t ocfs2_xattr_user_list(struct inode *inode, char *list,
- size_t list_size, const char *name,
- size_t name_len)
-{
- const size_t prefix_len = sizeof(XATTR_USER_PREFIX) - 1;
- const size_t total_len = prefix_len + name_len + 1;
- struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
-
- if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
- return 0;
-
- if (list && total_len <= list_size) {
- memcpy(list, XATTR_USER_PREFIX, prefix_len);
- memcpy(list + prefix_len, name, name_len);
- list[prefix_len + name_len] = '\0';
- }
- return total_len;
-}
-
-static int ocfs2_xattr_user_get(struct inode *inode, const char *name,
- void *buffer, size_t size)
-{
- struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
-
- if (strcmp(name, "") == 0)
- return -EINVAL;
- if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
- return -EOPNOTSUPP;
- return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name,
- buffer, size);
-}
-
-static int ocfs2_xattr_user_set(struct inode *inode, const char *name,
- const void *value, size_t size, int flags)
-{
- struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
-
- if (strcmp(name, "") == 0)
- return -EINVAL;
- if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
- return -EOPNOTSUPP;
-
- return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value,
- size, flags);
-}
-
-struct xattr_handler ocfs2_xattr_user_handler = {
- .prefix = XATTR_USER_PREFIX,
- .list = ocfs2_xattr_user_list,
- .get = ocfs2_xattr_user_get,
- .set = ocfs2_xattr_user_set,
-};
--
1.5.4.1
next prev parent reply other threads:[~2008-10-07 22:08 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 ` [PATCH 12/39] ocfs2: reserve inline space for extended attribute Mark Fasheh
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 [this message]
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=20081007220811.GG26373@wotan.suse.de \
--to=mfasheh@suse.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ocfs2-devel@oss.oracle.com \
--cc=tao.ma@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®