1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-29 16:44:03 +00:00

Space/style cleanups after last set of commits.

Approved by:	re (tmpfs blanket)
This commit is contained in:
Xin LI 2007-06-28 02:39:31 +00:00
parent a96539bf8f
commit a321f489a5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=171070
7 changed files with 71 additions and 72 deletions

View File

@ -299,7 +299,7 @@ struct tmpfs_mount {
/* maximum representable file size */
u_int64_t tm_maxfilesize;
/* Nodes are organized in two different lists. The used list
* contains all nodes that are currently used by the file system;
* i.e., they refer to existing files. The available list contains
@ -375,7 +375,7 @@ int tmpfs_chmod(struct vnode *, mode_t, struct ucred *, struct thread *);
int tmpfs_chown(struct vnode *, uid_t, gid_t, struct ucred *,
struct thread *);
int tmpfs_chsize(struct vnode *, u_quad_t, struct ucred *, struct thread *);
int tmpfs_chtimes(struct vnode *, struct timespec *, struct timespec *,
int tmpfs_chtimes(struct vnode *, struct timespec *, struct timespec *,
struct timespec *, int, struct ucred *, struct thread *);
void tmpfs_itimes(struct vnode *, const struct timespec *,
const struct timespec *);
@ -428,7 +428,7 @@ int tmpfs_truncate(struct vnode *, off_t);
* Returns information about the number of available memory pages,
* including physical and virtual ones.
*
* If 'total' is TRUE, the value returned is the total amount of memory
* If 'total' is TRUE, the value returned is the total amount of memory
* pages configured for the system (either in use or free).
* If it is FALSE, the value returned is the amount of free memory pages.
*
@ -462,7 +462,7 @@ TMPFS_PAGES_MAX(struct tmpfs_mount *tmp)
size_t freepages;
freepages = tmpfs_mem_info();
freepages -= freepages < TMPFS_PAGES_RESERVED ?
freepages -= freepages < TMPFS_PAGES_RESERVED ?
freepages : TMPFS_PAGES_RESERVED;
return MIN(tmp->tm_pages_max, freepages + tmp->tm_pages_used);

View File

@ -68,13 +68,13 @@ tmpfs_fifo_kqfilter(struct vop_kqfilter_args *ap)
switch (ap->a_kn->kn_filter){
case EVFILT_READ:
node->tn_status |= TMPFS_NODE_ACCESSED;
node->tn_status |= TMPFS_NODE_ACCESSED;
break;
case EVFILT_WRITE:
node->tn_status |= TMPFS_NODE_MODIFIED;
break;
}
return fifo_specops.vop_kqfilter(ap);
}
@ -86,7 +86,7 @@ tmpfs_fifo_close(struct vop_close_args *v)
struct tmpfs_node *node;
node = VP_TO_TMPFS_NODE(v->a_vp);
node->tn_status |= TMPFS_NODE_ACCESSED;
tmpfs_update(v->a_vp);
return fifo_specops.vop_close(v);
}

View File

@ -116,7 +116,7 @@ tmpfs_alloc_node(struct tmpfs_mount *tmp, enum vtype type,
nnode->tn_uid = uid;
nnode->tn_gid = gid;
nnode->tn_mode = mode;
/* Type-specific initialization. */
switch (nnode->tn_type) {
case VBLK:
@ -152,7 +152,7 @@ tmpfs_alloc_node(struct tmpfs_mount *tmp, enum vtype type,
break;
case VREG:
nnode->tn_reg.tn_aobj =
nnode->tn_reg.tn_aobj =
vm_pager_allocate(OBJT_SWAP, NULL, 0, VM_PROT_DEFAULT, 0);
nnode->tn_reg.tn_aobj_pages = 0;
break;
@ -328,7 +328,7 @@ tmpfs_alloc_vp(struct mount *mp, struct tmpfs_node *node, struct vnode **vpp,
if (node->tn_vnode != NULL) {
vp = node->tn_vnode;
vget(vp, LK_EXCLUSIVE | LK_RETRY, td);
/*
* Make sure the vnode is still there after
* getting the interlock to avoid racing a free.
@ -409,14 +409,14 @@ tmpfs_alloc_vp(struct mount *mp, struct tmpfs_node *node, struct vnode **vpp,
MPASS(node->tn_vpstate & TMPFS_VNODE_ALLOCATING);
TMPFS_NODE_LOCK(node);
node->tn_vpstate &= ~TMPFS_VNODE_ALLOCATING;
if (node->tn_vpstate & TMPFS_VNODE_WANT) {
node->tn_vpstate &= ~TMPFS_VNODE_WANT;
TMPFS_NODE_UNLOCK(node);
wakeup((caddr_t) &node->tn_vpstate);
} else
TMPFS_NODE_UNLOCK(node);
out:
*vpp = vp;
@ -597,7 +597,7 @@ tmpfs_dir_lookup(struct tmpfs_node *node, struct componentname *cnp)
}
}
node->tn_status |= TMPFS_NODE_ACCESSED;
return found ? de : NULL;
}
@ -875,7 +875,7 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize)
if (newpages < oldpages) {
VM_OBJECT_LOCK(uobj);
swap_pager_freespace(uobj,
swap_pager_freespace(uobj,
newpages, oldpages - newpages);
VM_OBJECT_UNLOCK(uobj);
}
@ -885,9 +885,9 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize)
*/
if (zerolen > 0) {
m = vm_page_grab(uobj, OFF_TO_IDX(newsize),
m = vm_page_grab(uobj, OFF_TO_IDX(newsize),
VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
pmap_zero_page_area(m, PAGE_SIZE - zerolen,
pmap_zero_page_area(m, PAGE_SIZE - zerolen,
zerolen);
vm_page_wakeup(m);
}
@ -1068,7 +1068,7 @@ tmpfs_chown(struct vnode *vp, uid_t uid, gid_t gid, struct ucred *cred,
* group of which we are not a member, the caller must have
* privilege.
*/
if ((uid != node->tn_uid ||
if ((uid != node->tn_uid ||
(gid != node->tn_gid && !groupmember(gid, cred))) &&
(error = priv_check_cred(cred, PRIV_VFS_CHOWN, 0)))
return (error);
@ -1178,7 +1178,7 @@ tmpfs_chtimes(struct vnode *vp, struct timespec *atime, struct timespec *mtime,
* several other file systems. Shouldn't this be centralized
* somewhere? */
if (cred->cr_uid != node->tn_uid &&
(error = suser_cred(cred, 0)) &&
(error = suser_cred(cred, 0)) &&
((vaflags & VA_UTIMES_NULL) == 0 ||
(error = VOP_ACCESS(vp, VWRITE, cred, l))))
return error;
@ -1191,9 +1191,9 @@ tmpfs_chtimes(struct vnode *vp, struct timespec *atime, struct timespec *mtime,
if (birthtime->tv_nsec != VNOVAL && birthtime->tv_nsec != VNOVAL)
node->tn_status |= TMPFS_NODE_MODIFIED;
tmpfs_itimes(vp, atime, mtime);
if (birthtime->tv_nsec != VNOVAL && birthtime->tv_nsec != VNOVAL)
node->tn_birthtime = *birthtime;
MPASS(VOP_ISLOCKED(vp, l));

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2007 Rohit Jalan (rohitj@purpe.com)
* Copyright (c) 2007 Rohit Jalan (rohitj@purpe.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -40,7 +40,7 @@ tmpfs_str_zone_create(struct tmpfs_str_zone *tsz)
len = TMPFS_STRZONE_STARTLEN;
for (i = 0; i < TMPFS_STRZONE_ZONECOUNT; ++i) {
tsz->tsz_zone[i] = uma_zcreate(
"TMPFS str", len,
"TMPFS str", len,
NULL, NULL, NULL, NULL,
UMA_ALIGN_PTR, 0);
len <<= 1;

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2007 Rohit Jalan (rohitj@purpe.com)
* Copyright (c) 2007 Rohit Jalan (rohitj@purpe.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -40,7 +40,7 @@ struct tmpfs_str_zone {
uma_zone_t tsz_zone[TMPFS_STRZONE_ZONECOUNT];
};
void tmpfs_str_zone_create(struct tmpfs_str_zone *);
void tmpfs_str_zone_create(struct tmpfs_str_zone *);
void tmpfs_str_zone_destroy(struct tmpfs_str_zone *);
static __inline char*

View File

@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
#include <fs/tmpfs/tmpfs.h>
/*
* Default permission for root node
* Default permission for root node
*/
#define TMPFS_DEFAULT_ROOT_MODE (S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
@ -83,7 +83,7 @@ static int tmpfs_statfs(struct mount *, struct statfs *, struct thread *);
/* --------------------------------------------------------------------- */
static const char *tmpfs_opts[] = {
"from", "size", "inodes", "uid", "gid", "mode",
"from", "size", "inodes", "uid", "gid", "mode",
NULL
};
@ -108,7 +108,7 @@ get_swpgtotal(void)
return total;
len = sizeof(nswapdev);
if (kernel_sysctlbyname(curthread, "vm.nswapdev",
if (kernel_sysctlbyname(curthread, "vm.nswapdev",
&nswapdev, &len,
NULL, 0, NULL, 0) != 0)
return total;
@ -117,7 +117,7 @@ get_swpgtotal(void)
oid[0] = 0;
oid[1] = 3;
if (kernel_sysctl(curthread, oid, 2,
if (kernel_sysctl(curthread, oid, 2,
soid, &mibi, (void *)sname, strlen(sname),
NULL, 0) != 0)
return total;
@ -126,8 +126,8 @@ get_swpgtotal(void)
for (unswdev = 0; unswdev < nswapdev; ++unswdev) {
soid[mibi] = unswdev;
len = sizeof(struct xswdev);
if (kernel_sysctl(curthread,
soid, mibi + 1, &xsd, &len, NULL, 0,
if (kernel_sysctl(curthread,
soid, mibi + 1, &xsd, &len, NULL, 0,
NULL, 0) != 0)
return total;
if (len == sizeof(struct xswdev))
@ -143,19 +143,18 @@ static int
tmpfs_node_ctor(void *mem, int size, void *arg, int flags)
{
struct tmpfs_node *node = (struct tmpfs_node *)mem;
if (node->tn_id == 0) {
/* if this node structure first time used */
struct tmpfs_mount *tmp = (struct tmpfs_mount *)arg;
TMPFS_LOCK(tmp);
node->tn_id = tmp->tm_nodes_last++;
TMPFS_UNLOCK(tmp);
node->tn_gen = arc4random();
}
else {
node->tn_gen = arc4random();
} else {
node->tn_gen++;
}
node->tn_size = 0;
node->tn_status = 0;
node->tn_flags = 0;
@ -175,14 +174,14 @@ tmpfs_node_dtor(void *mem, int size, void *arg)
node->tn_type = VNON;
}
static int
static int
tmpfs_node_init(void *mem, int size, int flags)
{
struct tmpfs_node *node = (struct tmpfs_node *)mem;
node->tn_id = 0;
mtx_init(&node->tn_interlock, "tmpfs node interlock", NULL, MTX_DEF);
return (0);
}
@ -190,7 +189,7 @@ static void
tmpfs_node_fini(void *mem, int size)
{
struct tmpfs_node *node = (struct tmpfs_node *)mem;
mtx_destroy(&node->tn_interlock);
}
@ -223,8 +222,8 @@ tmpfs_mount(struct mount *mp, struct thread *l)
if(vfs_scanopt(mp->mnt_optnew, "inodes", "%d", &args.ta_nodes_max) != 1)
args.ta_nodes_max = 0;
if(vfs_scanopt(mp->mnt_optnew,
"size",
if(vfs_scanopt(mp->mnt_optnew,
"size",
"%qu", &args.ta_size_max) != 1)
args.ta_size_max = 0;
@ -255,14 +254,14 @@ tmpfs_mount(struct mount *mp, struct thread *l)
/* Allocate the tmpfs mount structure and fill it. */
tmp = (struct tmpfs_mount *)malloc(sizeof(struct tmpfs_mount),
M_TMPFSMNT, M_WAITOK | M_ZERO);
mtx_init(&tmp->allnode_lock, "tmpfs allnode lock", NULL, MTX_DEF);
tmp->tm_nodes_max = nodes;
tmp->tm_nodes_last = 2;
tmp->tm_nodes_inuse = 0;
tmp->tm_maxfilesize = get_swpgtotal() * PAGE_SIZE;
LIST_INIT(&tmp->tm_nodes_used);
tmp->tm_pages_max = pages;
tmp->tm_pages_used = 0;
tmp->tm_dirent_pool = uma_zcreate(
@ -270,7 +269,7 @@ tmpfs_mount(struct mount *mp, struct thread *l)
sizeof(struct tmpfs_dirent),
NULL, NULL, NULL, NULL,
UMA_ALIGN_PTR,
0);
0);
tmp->tm_node_pool = uma_zcreate(
"TMPFS node",
sizeof(struct tmpfs_node),
@ -298,7 +297,7 @@ tmpfs_mount(struct mount *mp, struct thread *l)
mp->mnt_flag |= MNT_LOCAL;
mp->mnt_kern_flag |= MNTK_MPSAFE;
MNT_IUNLOCK(mp);
mp->mnt_data = tmp;
mp->mnt_stat.f_namemax = MAXNAMLEN;
vfs_getnewfsid(mp);
@ -328,7 +327,7 @@ tmpfs_unmount(struct mount *mp, int mntflags, struct thread *l)
return error;
tmp = VFS_TO_TMPFS(mp);
/* Free all associated data. The loop iterates over the linked list
* we have containing all used nodes. For each of them that is
* a directory, we free all its directory entries. Note that after
@ -367,7 +366,7 @@ tmpfs_unmount(struct mount *mp, int mntflags, struct thread *l)
/* Throw away the tmpfs_mount structure. */
free(mp->mnt_data, M_TMPFSMNT);
mp->mnt_data = NULL;
MNT_ILOCK(mp);
mp->mnt_flag &= ~MNT_LOCAL;
MNT_IUNLOCK(mp);
@ -433,7 +432,7 @@ tmpfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *l)
tmp = VFS_TO_TMPFS(mp);
sbp->f_iosize = PAGE_SIZE;
sbp->f_iosize = PAGE_SIZE;
sbp->f_bsize = PAGE_SIZE;
sbp->f_blocks = TMPFS_PAGES_MAX(tmp);

View File

@ -158,7 +158,7 @@ tmpfs_lookup(struct vop_cachedlookup_args *v)
cnp->cn_thread);
if (error != 0)
goto out;
/* Allocate a new vnode on the matching entry. */
error = tmpfs_alloc_vp(dvp->v_mount, tnode, vpp, td);
if (error != 0)
@ -171,7 +171,7 @@ tmpfs_lookup(struct vop_cachedlookup_args *v)
vput(*vpp);
*vpp = NULL;
goto out;
}
}
tnode->tn_lookup_dirent = de;
cnp->cn_flags |= SAVENAME;
}
@ -240,7 +240,7 @@ tmpfs_open(struct vop_open_args *v)
MPASS(VOP_ISLOCKED(vp, v->a_td));
node = VP_TO_TMPFS_NODE(vp);
/* The file is still active but all its names have been removed
* (e.g. by a "rmdir $(pwd)"). It cannot be opened any more as
* it is about to die. */
@ -252,7 +252,7 @@ tmpfs_open(struct vop_open_args *v)
error = EPERM;
else {
error = 0;
vnode_create_vobject(vp, node->tn_size, v->a_td);
vnode_create_vobject(vp, node->tn_size, v->a_td);
}
MPASS(VOP_ISLOCKED(vp, v->a_td));
@ -426,7 +426,7 @@ tmpfs_setattr(struct vop_setattr_args *v)
vap->va_mtime.tv_nsec != VNOVAL) ||
(vap->va_birthtime.tv_sec != VNOVAL &&
vap->va_birthtime.tv_nsec != VNOVAL)))
error = tmpfs_chtimes(vp, &vap->va_atime, &vap->va_mtime,
error = tmpfs_chtimes(vp, &vap->va_atime, &vap->va_mtime,
&vap->va_birthtime, vap->va_vaflags, cred, l);
/* Update the node times. We give preference to the error codes
@ -441,7 +441,7 @@ tmpfs_setattr(struct vop_setattr_args *v)
/* --------------------------------------------------------------------- */
static int
tmpfs_uio_xfer(struct tmpfs_mount *tmp, struct tmpfs_node *node,
tmpfs_uio_xfer(struct tmpfs_mount *tmp, struct tmpfs_node *node,
struct uio *uio, vm_object_t uobj)
{
struct sf_buf *sf;
@ -466,7 +466,7 @@ tmpfs_uio_xfer(struct tmpfs_mount *tmp, struct tmpfs_node *node,
idx = OFF_TO_IDX(uio->uio_offset);
d = uio->uio_offset - IDX_TO_OFF(idx);
len = MIN(len, (PAGE_SIZE - d));
m = vm_page_grab(uobj, idx, VM_ALLOC_WIRED | VM_ALLOC_ZERO |
m = vm_page_grab(uobj, idx, VM_ALLOC_WIRED | VM_ALLOC_ZERO |
VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
if (uio->uio_rw == UIO_READ && m->valid != VM_PAGE_BITS_ALL)
vm_page_zero_invalid(m, TRUE);
@ -557,8 +557,8 @@ tmpfs_write(struct vop_write_args *v)
if (ioflag & IO_APPEND)
uio->uio_offset = node->tn_size;
if (uio->uio_offset + uio->uio_resid >
if (uio->uio_offset + uio->uio_resid >
VFS_TO_TMPFS(vp->v_mount)->tm_maxfilesize)
return (EFBIG);
@ -732,7 +732,7 @@ tmpfs_link(struct vop_link_args *v)
tmpfs_update(vp);
error = 0;
out:
return error;
}
@ -792,21 +792,21 @@ tmpfs_rename(struct vop_rename_args *v)
}
MPASS(de->td_node == fnode);
/* If re-naming a directory to another preexisting directory
/* If re-naming a directory to another preexisting directory
* ensure that the target directory is empty so that its
* removal causes no side effects.
* removal causes no side effects.
* Kern_rename gurantees the destination to be a directory
* if the source is one. */
if (tvp != NULL) {
tnode = VP_TO_TMPFS_NODE(tvp);
if ((tnode->tn_flags & (NOUNLINK | IMMUTABLE | APPEND)) ||
(tdnode->tn_flags & (APPEND | IMMUTABLE))) {
error = EPERM;
goto out;
}
if ((de->td_node->tn_type == VDIR) && (tnode->tn_size > 0)) {
if ((de->td_node->tn_type == VDIR) && (tnode->tn_size > 0)) {
error = ENOTEMPTY;
goto out;
}
@ -967,12 +967,12 @@ tmpfs_rmdir(struct vop_rmdir_args *v)
dnode = VP_TO_TMPFS_DIR(dvp);
node = VP_TO_TMPFS_DIR(vp);
/* Directories with more than two entries ('.' and '..') cannot be
* removed. */
if (node->tn_size > 0) {
error = ENOTEMPTY;
goto out;
}
/* Directories with more than two entries ('.' and '..') cannot be
* removed. */
if (node->tn_size > 0) {
error = ENOTEMPTY;
goto out;
}
if ((dnode->tn_flags & APPEND)
|| (node->tn_flags & (NOUNLINK | IMMUTABLE | APPEND))) {
@ -980,8 +980,8 @@ tmpfs_rmdir(struct vop_rmdir_args *v)
goto out;
}
/* This invariant holds only if we are not trying to remove "..".
* We checked for that above so this is safe now. */
/* This invariant holds only if we are not trying to remove "..".
* We checked for that above so this is safe now. */
MPASS(node->tn_dir.tn_parent == dnode);
/* Get the directory entry associated with node (vp). This was
@ -1008,7 +1008,7 @@ tmpfs_rmdir(struct vop_rmdir_args *v)
node->tn_dir.tn_parent->tn_status |= TMPFS_NODE_ACCESSED | \
TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED;
cache_purge(dvp);
cache_purge(dvp);
cache_purge(vp);
/* Free the directory entry we just deleted. Note that the node
@ -1204,7 +1204,7 @@ tmpfs_reclaim(struct vop_reclaim_args *v)
node = VP_TO_TMPFS_NODE(vp);
tmp = VFS_TO_TMPFS(vp->v_mount);
vnode_destroy_vobject(vp);
cache_purge(vp);
tmpfs_free_vp(vp);
@ -1325,7 +1325,7 @@ tmpfs_vptofh(struct vop_vptofh_args *ap)
tfhp->tf_len = sizeof(struct tmpfs_fid);
tfhp->tf_id = node->tn_id;
tfhp->tf_gen = node->tn_gen;
return (0);
}