linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: viro@ZenIV.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 3/3] fs: make struct nameidata private to namei.c
Date: Mon, 18 Jun 2012 10:47:05 -0400	[thread overview]
Message-ID: <20120618144755.746981278@bombadil.infradead.org> (raw)
In-Reply-To: 20120618144702.856266417@bombadil.infradead.org

[-- Attachment #1: fs-make-nameidata-private --]
[-- Type: text/plain, Size: 4245 bytes --]

By moving nd_set_link and nd_get_link out of line we can hide the internals
of struct nameidata now.

Signed-off-by: Christoph Hellwig <hch@lst.de>

---
 Documentation/filesystems/porting |    6 ++++++
 fs/namei.c                        |   31 +++++++++++++++++++++++++++++++
 include/linux/namei.h             |   38 ++++++--------------------------------
 3 files changed, 43 insertions(+), 32 deletions(-)

Index: linux-2.6/fs/namei.c
===================================================================
--- linux-2.6.orig/fs/namei.c	2012-06-18 15:15:13.000371564 +0200
+++ linux-2.6/fs/namei.c	2012-06-18 15:20:46.920380115 +0200
@@ -110,6 +110,25 @@
  * any extra contention...
  */
 
+enum { MAX_NESTED_LINKS = 8 };
+
+/*
+ * Type of the last component on LOOKUP_PARENT
+ */
+enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
+
+struct nameidata {
+	struct path	path;
+	struct qstr	last;
+	struct path	root;
+	struct inode	*inode; /* path.dentry.d_inode */
+	unsigned int	flags;
+	unsigned	seq;
+	int		last_type;
+	unsigned	depth;
+	char *saved_names[MAX_NESTED_LINKS + 1];
+};
+
 /* In order to reduce some races, while at the same time doing additional
  * checking and hopefully speeding things up, we copy filenames to the
  * kernel data space before using them..
@@ -586,6 +605,18 @@ static inline void path_to_nameidata(con
 	nd->path.dentry = path->dentry;
 }
 
+void nd_set_link(struct nameidata *nd, char *path)
+{
+	nd->saved_names[nd->depth] = path;
+}
+EXPORT_SYMBOL(nd_set_link);
+
+char *nd_get_link(struct nameidata *nd)
+{
+	return nd->saved_names[nd->depth];
+}
+EXPORT_SYMBOL(nd_get_link);
+
 /*
  * Helper to directly jump to a known parsed path from ->follow_link,
  * caller must have taken a reference to path beforehand.
Index: linux-2.6/include/linux/namei.h
===================================================================
--- linux-2.6.orig/include/linux/namei.h	2012-06-18 15:15:13.000371564 +0200
+++ linux-2.6/include/linux/namei.h	2012-06-18 15:20:46.920380115 +0200
@@ -1,31 +1,13 @@
 #ifndef _LINUX_NAMEI_H
 #define _LINUX_NAMEI_H
 
-#include <linux/dcache.h>
-#include <linux/linkage.h>
-#include <linux/path.h>
+#include <linux/kernel.h>
 
+struct dentry;
+struct nameidata;
+struct path;
 struct vfsmount;
 
-enum { MAX_NESTED_LINKS = 8 };
-
-struct nameidata {
-	struct path	path;
-	struct qstr	last;
-	struct path	root;
-	struct inode	*inode; /* path.dentry.d_inode */
-	unsigned int	flags;
-	unsigned	seq;
-	int		last_type;
-	unsigned	depth;
-	char *saved_names[MAX_NESTED_LINKS + 1];
-};
-
-/*
- * Type of the last component on LOOKUP_PARENT
- */
-enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
-
 /*
  * The bitmask for a lookup event:
  *  - follow links at the end
@@ -80,18 +62,10 @@ extern int follow_up(struct path *);
 extern struct dentry *lock_rename(struct dentry *, struct dentry *);
 extern void unlock_rename(struct dentry *, struct dentry *);
 
+extern void nd_set_link(struct nameidata *nd, char *path);
+extern char *nd_get_link(struct nameidata *nd);
 extern void nd_jump_link(struct nameidata *nd, struct path *path);
 
-static inline void nd_set_link(struct nameidata *nd, char *path)
-{
-	nd->saved_names[nd->depth] = path;
-}
-
-static inline char *nd_get_link(struct nameidata *nd)
-{
-	return nd->saved_names[nd->depth];
-}
-
 static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
 {
 	((char *) name)[min(len, maxlen)] = '\0';
Index: linux-2.6/Documentation/filesystems/porting
===================================================================
--- linux-2.6.orig/Documentation/filesystems/porting	2012-06-18 15:15:13.000371564 +0200
+++ linux-2.6/Documentation/filesystems/porting	2012-06-18 15:20:46.920380115 +0200
@@ -442,3 +442,9 @@ d_make_root() drops the reference to ino
 two, it gets "is it an O_EXCL or equivalent?" boolean argument.  Note that
 local filesystems can ignore tha argument - they are guaranteed that the
 object doesn't exist.  It's remote/distributed ones that might care...
+
+--
+[mandatory]
+	struct nameidata is private to fs/namei.c now.  All ->follow_link
+	must now either use nd_set_link to set a link path to iterate on,
+	or nd_jump_link to jump to a pre-parsed struct path directly.


      parent reply	other threads:[~2012-06-18 14:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-18 14:47 [PATCH 0/3] make struct nameidata private to namei.c Christoph Hellwig
2012-06-18 14:47 ` [PATCH 1/3] fs: move path_put on failure out of ->follow_link Christoph Hellwig
2012-06-18 14:47 ` [PATCH 2/3] fs: add nd_jump_link Christoph Hellwig
2012-06-18 14:47 ` Christoph Hellwig [this message]

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=20120618144755.746981278@bombadil.infradead.org \
    --to=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).