From: Jonathan Nieder <jrnieder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "Myklebust,
Trond" <Trond.Myklebust-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org>
Cc: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>,
"669314-61a8vm9lEZVf4u+23C9RwQ@public.gmane.org"
<669314-61a8vm9lEZVf4u+23C9RwQ@public.gmane.org>,
"viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org"
<viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
"linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Micheal Waltz <mwaltz-zC7DfRvBq/JWk0Htik3J/w@public.gmane.org>,
Gabriel Evanoff <gevanoff-xrR1t/MlNfQ@public.gmane.org>,
"laurent+debian-IxsI/CcZGhYesTIZlEfwmg@public.gmane.org"
<laurent+debian-IxsI/CcZGhYesTIZlEfwmg@public.gmane.org>
Subject: [PATCH v3] nfs: Show original device name verbatim in /proc/*/mount{s,info}
Date: Wed, 31 Oct 2012 11:01:28 -0700 [thread overview]
Message-ID: <20121031180128.GC30432@elie.Belkin> (raw)
In-Reply-To: <4FA345DA4F4AE44899BD2B03EEEC2FA90929FA9E-VGJ86jkg8PeBTCzCEi1xmXOR4cbS7gtM96Bgd4bDwmQ@public.gmane.org>
From: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
Date: Sun, 21 Oct 2012 19:23:52 +0100
Since commit c7f404b ('vfs: new superblock methods to override
/proc/*/mount{s,info}'), nfs_path() is used to generate the mounted
device name reported back to userland.
nfs_path() always generates a trailing slash when the given dentry is
the root of an NFS mount, but userland may expect the original device
name to be returned verbatim (as it used to be). Make this
canonicalisation optional and change the callers accordingly.
[jrnieder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org: use flag instead of bool argument]
Reported-and-tested-by: Chris Hiestand <chiestand-xrR1t/MlNfQ@public.gmane.org>
Reference: http://bugs.debian.org/669314
Signed-off-by: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # v2.6.39+
Signed-off-by: Jonathan Nieder <jrnieder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
Myklebust, Trond wrote:
> This patch will not apply to the upstream kernel; it seems rather to
> have been generated incrementally against an older patch attempt.
I assume you mean the patch
nfs: convert boolean nfs_path() argument to a flag word
does not apply against master. It is just an optional code style
improvement on top of Ben's
nfs: Show original device name verbatim in /proc/*/mount{s,info}
Here are the two squashed together for convenience.
Thanks,
Jonathan
fs/nfs/internal.h | 5 +++--
fs/nfs/namespace.c | 19 ++++++++++++++-----
fs/nfs/nfs4namespace.c | 3 ++-
fs/nfs/super.c | 2 +-
4 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 59b133c5d652..a54fe51c1dfb 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -353,8 +353,9 @@ extern void nfs_sb_active(struct super_block *sb);
extern void nfs_sb_deactive(struct super_block *sb);
/* namespace.c */
+#define NFS_PATH_CANONICAL 1
extern char *nfs_path(char **p, struct dentry *dentry,
- char *buffer, ssize_t buflen);
+ char *buffer, ssize_t buflen, unsigned flags);
extern struct vfsmount *nfs_d_automount(struct path *path);
struct vfsmount *nfs_submount(struct nfs_server *, struct dentry *,
struct nfs_fh *, struct nfs_fattr *);
@@ -498,7 +499,7 @@ static inline char *nfs_devname(struct dentry *dentry,
char *buffer, ssize_t buflen)
{
char *dummy;
- return nfs_path(&dummy, dentry, buffer, buflen);
+ return nfs_path(&dummy, dentry, buffer, buflen, NFS_PATH_CANONICAL);
}
/*
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index 655925373b91..dd057bc6b65b 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -33,6 +33,7 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ;
* @dentry - pointer to dentry
* @buffer - result buffer
* @buflen - length of buffer
+ * @flags - options (see below)
*
* Helper function for constructing the server pathname
* by arbitrary hashed dentry.
@@ -40,8 +41,14 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ;
* This is mainly for use in figuring out the path on the
* server side when automounting on top of an existing partition
* and in generating /proc/mounts and friends.
+ *
+ * Supported flags:
+ * NFS_PATH_CANONICAL: ensure there is exactly one slash after
+ * the original device (export) name
+ * (if unset, the original name is returned verbatim)
*/
-char *nfs_path(char **p, struct dentry *dentry, char *buffer, ssize_t buflen)
+char *nfs_path(char **p, struct dentry *dentry, char *buffer, ssize_t buflen,
+ unsigned flags)
{
char *end;
int namelen;
@@ -74,7 +81,7 @@ rename_retry:
rcu_read_unlock();
goto rename_retry;
}
- if (*end != '/') {
+ if ((flags & NFS_PATH_CANONICAL) && *end != '/') {
if (--buflen < 0) {
spin_unlock(&dentry->d_lock);
rcu_read_unlock();
@@ -91,9 +98,11 @@ rename_retry:
return end;
}
namelen = strlen(base);
- /* Strip off excess slashes in base string */
- while (namelen > 0 && base[namelen - 1] == '/')
- namelen--;
+ if (flags & NFS_PATH_CANONICAL) {
+ /* Strip off excess slashes in base string */
+ while (namelen > 0 && base[namelen - 1] == '/')
+ namelen--;
+ }
buflen -= namelen;
if (buflen < 0) {
spin_unlock(&dentry->d_lock);
diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
index 79fbb61ce202..1e09eb78543b 100644
--- a/fs/nfs/nfs4namespace.c
+++ b/fs/nfs/nfs4namespace.c
@@ -81,7 +81,8 @@ static char *nfs_path_component(const char *nfspath, const char *end)
static char *nfs4_path(struct dentry *dentry, char *buffer, ssize_t buflen)
{
char *limit;
- char *path = nfs_path(&limit, dentry, buffer, buflen);
+ char *path = nfs_path(&limit, dentry, buffer, buflen,
+ NFS_PATH_CANONICAL);
if (!IS_ERR(path)) {
char *path_component = nfs_path_component(path, limit);
if (path_component)
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index e831bce49766..13c2a5be4765 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -771,7 +771,7 @@ int nfs_show_devname(struct seq_file *m, struct dentry *root)
int err = 0;
if (!page)
return -ENOMEM;
- devname = nfs_path(&dummy, root, page, PAGE_SIZE);
+ devname = nfs_path(&dummy, root, page, PAGE_SIZE, 0);
if (IS_ERR(devname))
err = PTR_ERR(devname);
else
--
1.8.0
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2012-10-31 18:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-19 19:43 Bug#669314: NFS: kernel forces trailing slash for export in /proc/self/mounts Chris Hiestand
2012-09-16 2:21 ` Ben Hutchings
2012-09-16 10:24 ` Bug#669314: " Chris Hiestand
[not found] ` <254E1AAA-BDE2-41A8-94D8-6E677860AD72-xrR1t/MlNfQ@public.gmane.org>
2012-09-16 14:00 ` Ben Hutchings
[not found] ` <1347804028.13258.267.camel-nDn/Rdv9kqW9Jme8/bJn5UCKIB8iOfG2tUK59QYPAWc@public.gmane.org>
2012-09-16 20:41 ` Chris Hiestand
[not found] ` <FB3CAE84-FDFE-4345-9F54-3295BDE2AD81-xrR1t/MlNfQ@public.gmane.org>
2012-09-30 21:23 ` Jonathan Nieder
[not found] ` <20120930212341.GA32505-fcEM2ccDkbL2nhBuCrrZHw@public.gmane.org>
2012-10-02 22:37 ` Chris Hiestand
[not found] ` <B259EBD8-0ED1-405F-A3E5-DF488FCE402F-xrR1t/MlNfQ@public.gmane.org>
2012-10-18 19:51 ` Chris Hiestand
[not found] ` <7941E5E1-488D-4D0B-A21A-4E389EF6EBBA-xrR1t/MlNfQ@public.gmane.org>
2012-10-21 18:23 ` [PATCH] nfs: Show original device name verbatim in /proc/*/mount{s,info} Ben Hutchings
2012-10-22 0:01 ` Jonathan Nieder
2012-10-31 17:45 ` Myklebust, Trond
[not found] ` <4FA345DA4F4AE44899BD2B03EEEC2FA90929FA9E-VGJ86jkg8PeBTCzCEi1xmXOR4cbS7gtM96Bgd4bDwmQ@public.gmane.org>
2012-10-31 18:01 ` Jonathan Nieder [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=20121031180128.GC30432@elie.Belkin \
--to=jrnieder-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=669314-61a8vm9lEZVf4u+23C9RwQ@public.gmane.org \
--cc=Trond.Myklebust-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org \
--cc=ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org \
--cc=gevanoff-xrR1t/MlNfQ@public.gmane.org \
--cc=laurent+debian-IxsI/CcZGhYesTIZlEfwmg@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mwaltz-zC7DfRvBq/JWk0Htik3J/w@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
/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).