Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/lfs Kill off ulfs_makedirentry; just pass the data t...
details: https://anonhg.NetBSD.org/src/rev/5c76114c2047
branches: trunk
changeset: 340586:5c76114c2047
user: dholland <dholland%NetBSD.org@localhost>
date: Tue Sep 15 15:00:32 2015 +0000
description:
Kill off ulfs_makedirentry; just pass the data to ulfs_direnter instead.
For now, move one copy of the code that allocates and fills in a
temporary struct lfs_direct to the top of ulfs_direnter; but it should
go away shortly.
diffstat:
sys/ufs/lfs/lfs_rename.c | 12 ++++-----
sys/ufs/lfs/lfs_vnops.c | 11 +++-----
sys/ufs/lfs/ulfs_extern.h | 11 +++-----
sys/ufs/lfs/ulfs_lookup.c | 55 ++++++++++++++++++++--------------------------
sys/ufs/lfs/ulfs_vnops.c | 26 ++++++---------------
5 files changed, 45 insertions(+), 70 deletions(-)
diffs (truncated from 322 to 300 lines):
diff -r 90aaa0cf2ff2 -r 5c76114c2047 sys/ufs/lfs/lfs_rename.c
--- a/sys/ufs/lfs/lfs_rename.c Tue Sep 15 14:59:58 2015 +0000
+++ b/sys/ufs/lfs/lfs_rename.c Tue Sep 15 15:00:32 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_rename.c,v 1.10 2015/09/15 14:58:06 dholland Exp $ */
+/* $NetBSD: lfs_rename.c,v 1.11 2015/09/15 15:00:32 dholland Exp $ */
/* from NetBSD: ufs_rename.c,v 1.6 2013/01/22 09:39:18 dholland Exp */
/*-
@@ -89,7 +89,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.10 2015/09/15 14:58:06 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.11 2015/09/15 15:00:32 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -770,7 +770,6 @@
struct ulfs_lookup_results *fulr = fde;
struct ulfs_lookup_results *tulr = tde;
bool directory_p, reparent_p;
- struct lfs_direct *newdir;
int error;
KASSERT(mp != NULL);
@@ -871,10 +870,9 @@
}
}
- newdir = pool_cache_get(ulfs_direct_cache, PR_WAITOK);
- ulfs_makedirentry(VTOI(fvp), tcnp, newdir);
- error = ulfs_direnter(tdvp, tulr, NULL, newdir, tcnp, NULL);
- pool_cache_put(ulfs_direct_cache, newdir);
+ error = ulfs_direnter(tdvp, tulr,
+ NULL, tcnp, VTOI(fvp)->i_number, LFS_IFTODT(VTOI(fvp)->i_mode),
+ NULL);
if (error) {
if (directory_p && reparent_p) {
/*
diff -r 90aaa0cf2ff2 -r 5c76114c2047 sys/ufs/lfs/lfs_vnops.c
--- a/sys/ufs/lfs/lfs_vnops.c Tue Sep 15 14:59:58 2015 +0000
+++ b/sys/ufs/lfs/lfs_vnops.c Tue Sep 15 15:00:32 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_vnops.c,v 1.289 2015/09/01 06:16:59 dholland Exp $ */
+/* $NetBSD: lfs_vnops.c,v 1.290 2015/09/15 15:00:32 dholland Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.289 2015/09/01 06:16:59 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.290 2015/09/15 15:00:32 dholland Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -858,7 +858,6 @@
struct ulfs_lookup_results *ulr;
struct buf *bp;
struct lfs_dirtemplate dirtemplate;
- struct lfs_direct *newdir;
int dirblksiz;
int error;
@@ -963,10 +962,8 @@
if ((error = lfs_update(tvp, NULL, NULL, UPDATE_DIROP)) != 0) {
goto bad;
}
- newdir = pool_cache_get(ulfs_direct_cache, PR_WAITOK);
- ulfs_makedirentry(ip, cnp, newdir);
- error = ulfs_direnter(dvp, ulr, tvp, newdir, cnp, bp);
- pool_cache_put(ulfs_direct_cache, newdir);
+ error = ulfs_direnter(dvp, ulr, tvp,
+ cnp, ip->i_number, LFS_IFTODT(ip->i_mode), bp);
bad:
if (error == 0) {
VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
diff -r 90aaa0cf2ff2 -r 5c76114c2047 sys/ufs/lfs/ulfs_extern.h
--- a/sys/ufs/lfs/ulfs_extern.h Tue Sep 15 14:59:58 2015 +0000
+++ b/sys/ufs/lfs/ulfs_extern.h Tue Sep 15 15:00:32 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ulfs_extern.h,v 1.16 2015/09/01 06:16:59 dholland Exp $ */
+/* $NetBSD: ulfs_extern.h,v 1.17 2015/09/15 15:00:32 dholland Exp $ */
/* from NetBSD: ufs_extern.h,v 1.72 2012/05/09 00:21:18 riastradh Exp */
/*-
@@ -112,13 +112,10 @@
/* ulfs_lookup.c */
void ulfs_dirbad(struct inode *, doff_t, const char *);
int ulfs_dirbadentry(struct vnode *, struct lfs_direct *, int);
-void ulfs_makedirentry(struct inode *, struct componentname *,
- struct lfs_direct *);
-void ulfs_makedirentry_bytype(struct lfs *, struct componentname *,
- ino_t, unsigned /*dtype*/, struct lfs_direct *);
int ulfs_direnter(struct vnode *, const struct ulfs_lookup_results *,
- struct vnode *, struct lfs_direct *,
- struct componentname *, struct buf *);
+ struct vnode *,
+ struct componentname *, ino_t, unsigned,
+ struct buf *);
int ulfs_dirremove(struct vnode *, const struct ulfs_lookup_results *,
struct inode *, int, int);
int ulfs_dirrewrite(struct inode *, off_t,
diff -r 90aaa0cf2ff2 -r 5c76114c2047 sys/ufs/lfs/ulfs_lookup.c
--- a/sys/ufs/lfs/ulfs_lookup.c Tue Sep 15 14:59:58 2015 +0000
+++ b/sys/ufs/lfs/ulfs_lookup.c Tue Sep 15 15:00:32 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ulfs_lookup.c,v 1.27 2015/09/15 14:58:06 dholland Exp $ */
+/* $NetBSD: ulfs_lookup.c,v 1.28 2015/09/15 15:00:32 dholland Exp $ */
/* from NetBSD: ufs_lookup.c,v 1.122 2013/01/22 09:39:18 dholland Exp */
/*
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.27 2015/09/15 14:58:06 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.28 2015/09/15 15:00:32 dholland Exp $");
#ifdef _KERNEL_OPT
#include "opt_lfs.h"
@@ -697,29 +697,18 @@
/*
* Construct a new directory entry after a call to namei, using the
- * name in the componentname argument cnp. The argument ip is the
- * inode to which the new directory entry will refer.
+ * name in the componentname argument cnp. The new directory entry
+ * will refer to inode INUM which has type (directory-level type)
+ * DTYPE. If adding a reference to an already-created or
+ * already-extant inode, these values are retrieved with:
+ * ip->i_number
+ * LFS_IFTODT(ip->i_mode)
+ * (The latter should be tidier. XXX)
*
* Does not set d_reclen.
*/
-void
-ulfs_makedirentry(struct inode *ip, struct componentname *cnp,
- struct lfs_direct *newdirp)
-{
- struct lfs *fs = ip->i_lfs;
-
- lfs_dir_setino(fs, newdirp, ip->i_number);
- memcpy(newdirp->d_name, cnp->cn_nameptr, (size_t)cnp->cn_namelen);
- newdirp->d_name[cnp->cn_namelen] = '\0';
- lfs_dir_setnamlen(fs, newdirp, cnp->cn_namelen);
- lfs_dir_settype(fs, newdirp, LFS_IFTODT(ip->i_mode));
-}
-
-/*
- * Similar but for special inodes.
- */
-void
-ulfs_makedirentry_bytype(struct lfs *fs, struct componentname *cnp,
+static void
+ulfs_makedirentry_tmp(struct lfs *fs, struct componentname *cnp,
ino_t inum, unsigned dtype, struct lfs_direct *newdirp)
{
lfs_dir_setino(fs, newdirp, inum);
@@ -736,20 +725,15 @@
* DVP is the directory to be updated. It must be locked.
* ULR is the ulfs_lookup_results structure from the final lookup step.
* TVP is not used. (XXX: why is it here? remove it)
- * DIRP is the new directory entry contents.
* CNP is the componentname from the final lookup step.
+ * INUM is the inode number to insert into the new directory entry.
+ * DTYPE is the type code (LFS_DT_*) to insert into the new directory entry.
* NEWDIRBP is not used and (XXX) should be removed. The previous
* comment here said it was used by the now-removed softupdates code.
*
* The link count of the target inode is *not* incremented; the
* caller does that.
*
- * DIRP should have been filled in by ulfs_makedirentry(). Manual
- * initialization should be avoided, but if needed should be
- * equivalent to ulfs_makedirentry in byteswapping, use of accessor
- * functions, etc.; otherwise we might byteswap too many times or not
- * enough.
- *
* If ulr->ulr_count is 0, ulfs_lookup did not find space to insert the
* directory entry. ulr_offset, which is the place to put the entry,
* should be on a block boundary (and should be at the end of the
@@ -766,8 +750,9 @@
*/
int
ulfs_direnter(struct vnode *dvp, const struct ulfs_lookup_results *ulr,
- struct vnode *tvp, struct lfs_direct *dirp,
- struct componentname *cnp, struct buf *newdirbp)
+ struct vnode *tvp,
+ struct componentname *cnp, ino_t inum, unsigned dtype,
+ struct buf *newdirbp)
{
kauth_cred_t cr;
int newentrysize;
@@ -781,6 +766,10 @@
struct ulfsmount *ump = VFSTOULFS(dvp->v_mount);
struct lfs *fs = ump->um_lfs;
int dirblksiz = fs->um_dirblksiz;
+ struct lfs_direct *dirp;
+
+ dirp = pool_cache_get(ulfs_direct_cache, PR_WAITOK);
+ ulfs_makedirentry_tmp(fs, cnp, inum, dtype, dirp);
error = 0;
cr = cnp->cn_cred;
@@ -799,6 +788,7 @@
panic("ulfs_direnter: newblk");
if ((error = lfs_balloc(dvp, (off_t)ulr->ulr_offset, dirblksiz,
cr, B_CLRBUF | B_SYNC, &bp)) != 0) {
+ pool_cache_put(ulfs_direct_cache, dirp);
return (error);
}
dp->i_size = ulr->ulr_offset + dirblksiz;
@@ -818,6 +808,7 @@
error = VOP_BWRITE(bp->b_vp, bp);
vfs_timestamp(&ts);
ret = lfs_update(dvp, &ts, &ts, UPDATE_DIROP);
+ pool_cache_put(ulfs_direct_cache, dirp);
if (error == 0)
return (ret);
return (error);
@@ -853,6 +844,7 @@
*/
error = ulfs_blkatoff(dvp, (off_t)ulr->ulr_offset, &dirbuf, &bp, true);
if (error) {
+ pool_cache_put(ulfs_direct_cache, dirp);
return (error);
}
/*
@@ -950,6 +942,7 @@
#endif
(void) lfs_truncate(dvp, (off_t)ulr->ulr_endoff, IO_SYNC, cr);
}
+ pool_cache_put(ulfs_direct_cache, dirp);
return (error);
}
diff -r 90aaa0cf2ff2 -r 5c76114c2047 sys/ufs/lfs/ulfs_vnops.c
--- a/sys/ufs/lfs/ulfs_vnops.c Tue Sep 15 14:59:58 2015 +0000
+++ b/sys/ufs/lfs/ulfs_vnops.c Tue Sep 15 15:00:32 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ulfs_vnops.c,v 1.29 2015/09/15 14:58:06 dholland Exp $ */
+/* $NetBSD: ulfs_vnops.c,v 1.30 2015/09/15 15:00:32 dholland Exp $ */
/* from NetBSD: ufs_vnops.c,v 1.213 2013/06/08 05:47:02 kardel Exp */
/*-
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.29 2015/09/15 14:58:06 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.30 2015/09/15 15:00:32 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@@ -554,7 +554,6 @@
struct componentname *cnp = ap->a_cnp;
struct mount *mp = dvp->v_mount;
struct inode *ip;
- struct lfs_direct *newdir;
int error;
struct ulfs_lookup_results *ulr;
@@ -588,10 +587,8 @@
ip->i_flag |= IN_CHANGE;
error = lfs_update(vp, NULL, NULL, UPDATE_DIROP);
if (!error) {
- newdir = pool_cache_get(ulfs_direct_cache, PR_WAITOK);
- ulfs_makedirentry(ip, cnp, newdir);
- error = ulfs_direnter(dvp, ulr, vp, newdir, cnp, NULL);
- pool_cache_put(ulfs_direct_cache, newdir);
+ error = ulfs_direnter(dvp, ulr, vp,
+ cnp, ip->i_number, LFS_IFTODT(ip->i_mode), NULL);
}
if (error) {
ip->i_nlink--;
@@ -620,7 +617,6 @@
} */ *ap = v;
struct vnode *dvp = ap->a_dvp;
struct componentname *cnp = ap->a_cnp;
- struct lfs_direct *newdir;
int error;
struct ulfsmount *ump = VFSTOULFS(dvp->v_mount);
struct lfs *fs = ump->um_lfs;
@@ -646,11 +642,8 @@
panic("ulfs_whiteout: old format filesystem");
#endif
- newdir = pool_cache_get(ulfs_direct_cache, PR_WAITOK);
- ulfs_makedirentry_bytype(fs, cnp, ULFS_WINO, LFS_DT_WHT,
- newdir);
- error = ulfs_direnter(dvp, ulr, NULL, newdir, cnp, NULL);
- pool_cache_put(ulfs_direct_cache, newdir);
+ error = ulfs_direnter(dvp, ulr, NULL,
+ cnp, ULFS_WINO, LFS_DT_WHT, NULL);
break;
Home |
Main Index |
Thread Index |
Old Index