aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs3xdr.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2007-02-14 03:33:12 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-14 11:09:53 -0500
commitaf6a4e280e3ff453653f39190b57b345ff0bec16 (patch)
tree4895c90613737db7354f43431ed10a55dc0c98f0 /fs/nfsd/nfs3xdr.c
parent982aedfd091e6d9831216f8519f12242091be4fd (diff)
[PATCH] knfsd: add some new fsid types
Add support for using a filesystem UUID to identify and export point in the filehandle. For NFSv2, this UUID is xor-ed down to 4 or 8 bytes so that it doesn't take up too much room. For NFSv3+, we use the full 16 bytes, and possibly also a 64bit inode number for exports beneath the root of a filesystem. When generating an fsid to return in 'stat' information, use the UUID (hashed down to size) if it is available and a small 'fsid' was not specifically provided. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/nfsd/nfs3xdr.c')
-rw-r--r--fs/nfsd/nfs3xdr.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index e695660921ec..6f677988c71d 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -149,6 +149,27 @@ decode_sattr3(__be32 *p, struct iattr *iap)
149 return p; 149 return p;
150} 150}
151 151
152static __be32 *encode_fsid(__be32 *p, struct svc_fh *fhp)
153{
154 u64 f;
155 switch(fsid_source(fhp)) {
156 default:
157 case FSIDSOURCE_DEV:
158 p = xdr_encode_hyper(p, (u64)huge_encode_dev
159 (fhp->fh_dentry->d_inode->i_sb->s_dev));
160 break;
161 case FSIDSOURCE_FSID:
162 p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid);
163 break;
164 case FSIDSOURCE_UUID:
165 f = ((u64*)fhp->fh_export->ex_uuid)[0];
166 f ^= ((u64*)fhp->fh_export->ex_uuid)[1];
167 p = xdr_encode_hyper(p, f);
168 break;
169 }
170 return p;
171}
172
152static __be32 * 173static __be32 *
153encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, 174encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
154 struct kstat *stat) 175 struct kstat *stat)
@@ -169,10 +190,7 @@ encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
169 p = xdr_encode_hyper(p, ((u64)stat->blocks) << 9); 190 p = xdr_encode_hyper(p, ((u64)stat->blocks) << 9);
170 *p++ = htonl((u32) MAJOR(stat->rdev)); 191 *p++ = htonl((u32) MAJOR(stat->rdev));
171 *p++ = htonl((u32) MINOR(stat->rdev)); 192 *p++ = htonl((u32) MINOR(stat->rdev));
172 if (is_fsid(fhp, rqstp->rq_reffh)) 193 p = encode_fsid(p, fhp);
173 p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid);
174 else
175 p = xdr_encode_hyper(p, (u64) huge_encode_dev(stat->dev));
176 p = xdr_encode_hyper(p, (u64) stat->ino); 194 p = xdr_encode_hyper(p, (u64) stat->ino);
177 p = encode_time3(p, &stat->atime); 195 p = encode_time3(p, &stat->atime);
178 lease_get_mtime(dentry->d_inode, &time); 196 lease_get_mtime(dentry->d_inode, &time);
@@ -203,10 +221,7 @@ encode_saved_post_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
203 p = xdr_encode_hyper(p, ((u64)fhp->fh_post_blocks) << 9); 221 p = xdr_encode_hyper(p, ((u64)fhp->fh_post_blocks) << 9);
204 *p++ = fhp->fh_post_rdev[0]; 222 *p++ = fhp->fh_post_rdev[0];
205 *p++ = fhp->fh_post_rdev[1]; 223 *p++ = fhp->fh_post_rdev[1];
206 if (is_fsid(fhp, rqstp->rq_reffh)) 224 p = encode_fsid(p, fhp);
207 p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid);
208 else
209 p = xdr_encode_hyper(p, (u64)huge_encode_dev(inode->i_sb->s_dev));
210 p = xdr_encode_hyper(p, (u64) inode->i_ino); 225 p = xdr_encode_hyper(p, (u64) inode->i_ino);
211 p = encode_time3(p, &fhp->fh_post_atime); 226 p = encode_time3(p, &fhp->fh_post_atime);
212 p = encode_time3(p, &fhp->fh_post_mtime); 227 p = encode_time3(p, &fhp->fh_post_mtime);