From: "J. Bruce Fields" <bfields@fieldses.org>
To: lioupayphone <lioupayphone@gmail.com>
Cc: linux-nfs <linux-nfs@vger.kernel.org>
Subject: Re: what's the real meaning of fsid?
Date: Thu, 18 Dec 2008 14:03:55 -0500 [thread overview]
Message-ID: <20081218190355.GA31478@fieldses.org> (raw)
In-Reply-To: <200812171336070316863@gmail.com>
On Wed, Dec 17, 2008 at 01:36:12PM +0800, lioupayphone wrote:
> Hello, everyone.
>
> fsid in /etc/exports was used for identifying a file system. if a file system which exported 2 directories, it seems that we should tag the two export entries with same fsid.
>
> eg
> on one machine (server 10.10.37.147, Centos5.2 with linux2.6.18):
>
> #mkfs.ext3 /dev/sdc; mount /dev/sdc /mnt/;mkdir -p /mnt/dir1 /mnt/dir2; touch /mnt/dir1/wall-e /mnt/dir2/eva;
> #echo "/mnt/dir1 *(rw,async,root_squash,fsid=2)" > /etc/exports
> #echo "/mnt/dir2 *(rw,async,root_squash,fsid=2)" >> /etc/exports
That's an odd thing to do; could you explain what you're trying to
accomplish?
--b.
> #service nfs start && exportfs -r
>
> on another machine (client 10.10.37.154):
> #mount 10.10.37.147:/mnt/dir1 /mnt/1/ && mount 10.10.37.147:/mnt/dir2 /mnt/2/
>
> i am puzzled: on the client (10.10.37.154), i found both "/mnt/1/" and "/mnt/2/" have the same child ---- "wall-e".
>
> so i browsed the code of 2.6.18 and found: exp_export(), fs/nfsd/export.c . i have taged a comment on this code listed below. please give me some suggestions. thx.
>
> /*
> * Export a file system.
> */
> int
> exp_export(struct nfsctl_export *nxp)
> {
> svc_client *clp;
> struct svc_export *exp = NULL;
> struct svc_export new;
> struct svc_expkey *fsid_key = NULL;
> struct nameidata nd;
> int err;
>
> /* Consistency check */
> err = -EINVAL;
> if (!exp_verify_string(nxp->ex_path, NFS_MAXPATHLEN) ||
> !exp_verify_string(nxp->ex_client, NFSCLNT_IDMAX))
> goto out;
>
> dprintk("exp_export called for %s:%s (%x/%ld fl %x).\n",
> nxp->ex_client, nxp->ex_path,
> (unsigned)nxp->ex_dev, (long)nxp->ex_ino,
> nxp->ex_flags);
>
> /* Try to lock the export table for update */
> exp_writelock();
>
> /* Look up client info */
> if (!(clp = auth_domain_find(nxp->ex_client)))
> goto out_unlock;
>
>
> /* Look up the dentry */
> err = path_lookup(nxp->ex_path, 0, &nd);
> if (err)
> goto out_unlock;
> err = -EINVAL;
>
> exp = exp_get_by_name(clp, nd.mnt, nd.dentry, NULL);
>
> /* must make sure there won't be an ex_fsid clash */
> if ((nxp->ex_flags & NFSEXP_FSID) &&
> (fsid_key = exp_get_fsid_key(clp, nxp->ex_dev)) &&
> !IS_ERR(fsid_key) &&
> fsid_key->ek_mnt &&
> /*
> * --> HERE. "nd.mnt of "/mnt/dir1" and "/mnt/dir2" are same, but nd.dentry not.
> * "(fsid_key->ek_mnt != nd.mnt || fsid_key->ek_dentry != nd.dentry)" will be 1 in such
> * a situation. but they are different exp-entries in "/var/lib/nfs/etab"
> * it should be "(fsid_key->ek_dentry != nd.dentry || fsid_key->ek_mnt != nd.mnt)" ??
> */
> (fsid_key->ek_mnt != nd.mnt || fsid_key->ek_dentry != nd.dentry) )
> goto finish;
>
> if (exp) {
> /* just a flags/id/fsid update */
>
> exp_fsid_unhash(exp);
> exp->ex_flags = nxp->ex_flags;
> exp->ex_anon_uid = nxp->ex_anon_uid;
> exp->ex_anon_gid = nxp->ex_anon_gid;
> exp->ex_fsid = nxp->ex_dev;
>
> err = exp_fsid_hash(clp, exp);
> goto finish;
> }
>
> err = check_export(nd.dentry->d_inode, nxp->ex_flags);
> if (err) goto finish;
>
> err = -ENOMEM;
>
> dprintk("nfsd: creating export entry %p for client %p\n", exp, clp);
>
> new.h.expiry_time = NEVER;
> new.h.flags = 0;
> new.ex_client = clp;
> new.ex_mnt = nd.mnt;
> new.ex_dentry = nd.dentry;
> new.ex_flags = nxp->ex_flags;
> new.ex_anon_uid = nxp->ex_anon_uid;
> new.ex_anon_gid = nxp->ex_anon_gid;
> new.ex_fsid = nxp->ex_dev;
>
> exp = svc_export_lookup(&new);
> if (exp)
> exp = svc_export_update(&new, exp);
>
> if (!exp)
> goto finish;
>
> if (exp_hash(clp, exp) ||
> exp_fsid_hash(clp, exp)) {
> /* failed to create at least one index */
> exp_do_unexport(exp);
> cache_flush();
> err = -ENOMEM;
> }
>
> finish:
> if (exp)
> exp_put(exp);
> if (fsid_key && !IS_ERR(fsid_key))
> cache_put(&fsid_key->h, &svc_expkey_cache);
> if (clp)
> auth_domain_put(clp);
> path_release(&nd);
> out_unlock:
> exp_writeunlock();
> out:
> return err;
> }
>
>
>
> Best Regards!
> lioupayphone
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2008-12-18 19:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-17 5:36 what's the real meaning of fsid? lioupayphone
2008-12-17 22:32 ` Steve Dickson
2008-12-18 1:16 ` lioupayphone
2008-12-18 15:21 ` Steve Dickson
2008-12-18 19:03 ` J. Bruce Fields [this message]
2008-12-19 15:04 ` lioupayphone
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=20081218190355.GA31478@fieldses.org \
--to=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
--cc=lioupayphone@gmail.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.