Set stat->st_dev and statfs->f_fsid

Filesystems like ZFS must use what the kernel calls an anonymous super
block.  Basically, this is just a filesystem which is not backed by a
single block device.  Normally this block device's dev_t is stored in
the super block.  For anonymous super blocks a unique reserved dev_t
is assigned as part of get_sb().

This sb->s_dev must then be set in the returned stat structures as
stat->st_dev.  This allows userspace utilities to easily detect the
boundries of a specific filesystem.  Tools such as 'du' depend on this
for proper accounting.

Additionally, under OpenSolaris the statfs->f_fsid is set to the device
id.  To preserve consistency with OpenSolaris we also set the fsid to
the device id.  Other Linux filesystem (ext) set the fsid to a unique
value determined by the filesystems uuid.  This value is unique but
maintains no relationship to the device id.  This may be desirable
when exporting NFS filesystem because it minimizes to chance of a
client observing the same fsid from two different servers.

Closes #140
This commit is contained in:
Brian Behlendorf 2011-03-07 16:06:22 -08:00
parent a60b1c0a8e
commit 53cf50e081
3 changed files with 3 additions and 3 deletions

View File

@ -1029,7 +1029,7 @@ zfs_statvfs(struct dentry *dentry, struct kstatfs *statp)
*/ */
statp->f_ffree = MIN(availobjs, statp->f_bfree); statp->f_ffree = MIN(availobjs, statp->f_bfree);
statp->f_files = statp->f_ffree + usedobjs; statp->f_files = statp->f_ffree + usedobjs;
statp->f_fsid.val[0] = 0; /* XXX: Map up some unique ID */ statp->f_fsid.val[0] = dentry->d_sb->s_dev;
statp->f_fsid.val[1] = 0; statp->f_fsid.val[1] = 0;
statp->f_type = ZFS_SUPER_MAGIC; statp->f_type = ZFS_SUPER_MAGIC;
statp->f_namelen = ZFS_MAXNAMELEN; statp->f_namelen = ZFS_MAXNAMELEN;

View File

@ -2084,7 +2084,7 @@ zfs_getattr(struct inode *ip, vattr_t *vap, int flags, cred_t *cr)
mutex_enter(&zp->z_lock); mutex_enter(&zp->z_lock);
vap->va_type = vn_mode_to_vtype(zp->z_mode); vap->va_type = vn_mode_to_vtype(zp->z_mode);
vap->va_mode = zp->z_mode; vap->va_mode = zp->z_mode;
vap->va_fsid = 0; vap->va_fsid = ZTOI(zp)->i_sb->s_dev;
vap->va_nodeid = zp->z_id; vap->va_nodeid = zp->z_id;
if ((zp->z_id == zsb->z_root) && zfs_show_ctldir(zp)) if ((zp->z_id == zsb->z_root) && zfs_show_ctldir(zp))
links = zp->z_links + 1; links = zp->z_links + 1;

View File

@ -184,7 +184,7 @@ zpl_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
goto out; goto out;
stat->ino = ip->i_ino; stat->ino = ip->i_ino;
stat->dev = 0; stat->dev = ip->i_sb->s_dev;
stat->mode = vap->va_mode; stat->mode = vap->va_mode;
stat->nlink = vap->va_nlink; stat->nlink = vap->va_nlink;
stat->uid = vap->va_uid; stat->uid = vap->va_uid;