Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/tmpfs/tmpfs_vfsops.c
Show First 20 Lines • Show All 579 Lines • ▼ Show 20 Lines | if (error == 0) | ||||
(*vpp)->v_vflag |= VV_ROOT; | (*vpp)->v_vflag |= VV_ROOT; | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
tmpfs_fhtovp(struct mount *mp, struct fid *fhp, int flags, | tmpfs_fhtovp(struct mount *mp, struct fid *fhp, int flags, | ||||
struct vnode **vpp) | struct vnode **vpp) | ||||
{ | { | ||||
struct tmpfs_fid_data tfd; | struct tmpfs_fid_data *tfd; | ||||
struct tmpfs_mount *tmp; | struct tmpfs_mount *tmp; | ||||
struct tmpfs_node *node; | struct tmpfs_node *node; | ||||
int error; | int error; | ||||
if (fhp->fid_len != sizeof(tfd)) | if (fhp->fid_len != sizeof(*tfd)) | ||||
return (EINVAL); | return (EINVAL); | ||||
/* | tfd = (struct tmpfs_fid_data *)fhp; | ||||
* Copy from fid_data onto the stack to avoid unaligned pointer use. | |||||
* See the comment in sys/mount.h on struct fid for details. | |||||
*/ | |||||
memcpy(&tfd, fhp->fid_data, fhp->fid_len); | |||||
tmp = VFS_TO_TMPFS(mp); | tmp = VFS_TO_TMPFS(mp); | ||||
if (tfd.tfd_id >= tmp->tm_nodes_max) | if (tfd->tfd_id >= tmp->tm_nodes_max) | ||||
return (EINVAL); | return (EINVAL); | ||||
TMPFS_LOCK(tmp); | TMPFS_LOCK(tmp); | ||||
LIST_FOREACH(node, &tmp->tm_nodes_used, tn_entries) { | LIST_FOREACH(node, &tmp->tm_nodes_used, tn_entries) { | ||||
if (node->tn_id == tfd.tfd_id && | if (node->tn_id == tfd->tfd_id && | ||||
node->tn_gen == tfd.tfd_gen) { | node->tn_gen == tfd->tfd_gen) { | ||||
markj: Not related to your change, but this loop seems rather suboptimal. It looks like tmpfs has no… | |||||
olceAuthorUnsubmitted Done Inline ActionsIndeed... I mentioned this problem a few comments ago, saying that it caused the performance of __packed versus aligned fields to become second order at best. olce: Indeed... I mentioned this problem a few comments ago, saying that it caused the performance of… | |||||
tmpfs_ref_node(node); | tmpfs_ref_node(node); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
TMPFS_UNLOCK(tmp); | TMPFS_UNLOCK(tmp); | ||||
if (node != NULL) { | if (node != NULL) { | ||||
error = tmpfs_alloc_vp(mp, node, LK_EXCLUSIVE, vpp); | error = tmpfs_alloc_vp(mp, node, LK_EXCLUSIVE, vpp); | ||||
▲ Show 20 Lines • Show All 130 Lines • Show Last 20 Lines |
Not related to your change, but this loop seems rather suboptimal. It looks like tmpfs has no efficient way to map an inode number to a vnode.