Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/ufs comments and cosmetics. no functional changes.



details:   https://anonhg.NetBSD.org/src/rev/006d6c5647e2
branches:  trunk
changeset: 779120:006d6c5647e2
user:      yamt <yamt%NetBSD.org@localhost>
date:      Sat May 05 04:08:53 2012 +0000

description:
comments and cosmetics.  no functional changes.

diffstat:

 sys/ufs/ufs/inode.h      |   5 +++-
 sys/ufs/ufs/ufs_lookup.c |  60 ++++++++++++++++++++++++++++-------------------
 2 files changed, 40 insertions(+), 25 deletions(-)

diffs (188 lines):

diff -r a3762cdfa2c4 -r 006d6c5647e2 sys/ufs/ufs/inode.h
--- a/sys/ufs/ufs/inode.h       Sat May 05 01:29:56 2012 +0000
+++ b/sys/ufs/ufs/inode.h       Sat May 05 04:08:53 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inode.h,v 1.59 2012/01/02 22:10:45 perseant Exp $      */
+/*     $NetBSD: inode.h,v 1.60 2012/05/05 04:08:53 yamt Exp $  */
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -50,6 +50,9 @@
  * Lookup result state (other than the result inode). This is
  * currently stashed in the vnode between VOP_LOOKUP and directory
  * operation VOPs, which is gross.
+ *
+ * XXX ulr_diroff is a lookup hint from the previos call of VOP_LOOKUP.
+ * probably it should not be here.
  */
 struct ufs_lookup_results {
        int32_t   ulr_count;    /* Size of free slot in directory. */
diff -r a3762cdfa2c4 -r 006d6c5647e2 sys/ufs/ufs/ufs_lookup.c
--- a/sys/ufs/ufs/ufs_lookup.c  Sat May 05 01:29:56 2012 +0000
+++ b/sys/ufs/ufs/ufs_lookup.c  Sat May 05 04:08:53 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_lookup.c,v 1.113 2012/03/16 08:39:54 hannken Exp $ */
+/*     $NetBSD: ufs_lookup.c,v 1.114 2012/05/05 04:08:53 yamt Exp $    */
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.113 2012/03/16 08:39:54 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.114 2012/05/05 04:08:53 yamt Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -124,19 +124,27 @@
        struct buf *bp;                 /* a buffer of directory entries */
        struct direct *ep;              /* the current directory entry */
        int entryoffsetinblock;         /* offset of ep in bp's buffer */
-       enum {NONE, COMPACT, FOUND} slotstatus;
-       doff_t slotoffset;              /* offset of area with free space */
+       enum {
+               NONE,           /* need to search a slot for our new entry */
+               COMPACT,        /* a compaction can make a slot in the current
+                                  DIRBLKSIZ block */
+               FOUND,          /* found a slot (or no need to search) */
+       } slotstatus;
+       doff_t slotoffset;              /* offset of area with free space.
+                                          a special value -1 for invalid */
        int slotsize;                   /* size of area at slotoffset */
-       int slotfreespace;              /* amount of space free in slot */
+       int slotfreespace;              /* accumulated amount of space free in
+                                          the current DIRBLKSIZ block */
        int slotneeded;                 /* size of the entry we're seeking */
        int numdirpasses;               /* strategy for directory search */
        doff_t endsearch;               /* offset to end directory search */
-       doff_t prevoff;                 /* prev entry dp->i_offset */
+       doff_t prevoff;                 /* previous value of ulr_offset */
        struct vnode *pdp;              /* saved dp during symlink work */
        struct vnode *tdp;              /* returned by VFS_VGET */
-       doff_t enduseful;               /* pointer past last used dir slot */
+       doff_t enduseful;               /* pointer past last used dir slot.
+                                          used for directory truncation. */
        u_long bmask;                   /* block offset mask */
-       int namlen, error;
+       int error;
        struct vnode **vpp = ap->a_vpp;
        struct componentname *cnp = ap->a_cnp;
        kauth_cred_t cred = cnp->cn_cred;
@@ -194,8 +202,7 @@
         */
        slotstatus = FOUND;
        slotfreespace = slotsize = slotneeded = 0;
-       if ((nameiop == CREATE || nameiop == RENAME) &&
-           (flags & ISLASTCN)) {
+       if ((nameiop == CREATE || nameiop == RENAME) && (flags & ISLASTCN)) {
                slotstatus = NONE;
                slotneeded = DIRECTSIZ(cnp->cn_namelen);
        }
@@ -280,8 +287,8 @@
                if ((results->ulr_offset & bmask) == 0) {
                        if (bp != NULL)
                                brelse(bp, 0);
-                       error = ufs_blkatoff(vdp, (off_t)results->ulr_offset, NULL,
-                           &bp, false);
+                       error = ufs_blkatoff(vdp, (off_t)results->ulr_offset,
+                           NULL, &bp, false);
                        if (error)
                                goto out;
                        entryoffsetinblock = 0;
@@ -351,6 +358,8 @@
                 * Check for a name match.
                 */
                if (ep->d_ino) {
+                       int namlen;
+
 #if (BYTE_ORDER == LITTLE_ENDIAN)
                        if (FSFMT(vdp) && needswap == 0)
                                namlen = ep->d_type;
@@ -370,8 +379,7 @@
 #endif
                                /*
                                 * Save directory entry's inode number and
-                                * reclen in ndp->ni_ufs area, and release
-                                * directory buffer.
+                                * reclen, and release directory buffer.
                                 */
                                if (!FSFMT(vdp) && ep->d_type == DT_WHT) {
                                        slotstatus = FOUND;
@@ -380,8 +388,9 @@
                                            needswap);
                                        results->ulr_reclen = slotsize;
                                        /*
-                                        * This is used to set results->ulr_endoff,
-                                        * which may be used by ufs_direnter2()
+                                        * This is used to set
+                                        * results->ulr_endoff,
+                                        * which may be used by ufs_direnter()
                                         * as a length to truncate the
                                         * directory to.  Therefore, it must
                                         * point past the end of the last
@@ -396,12 +405,13 @@
                                         * an existing entry anyway.
                                         */
                                        enduseful = endsearch;
-                                       ap->a_cnp->cn_flags |= ISWHITEOUT;
+                                       cnp->cn_flags |= ISWHITEOUT;
                                        numdirpasses--;
                                        goto notfound;
                                }
                                foundino = ufs_rw32(ep->d_ino, needswap);
-                               results->ulr_reclen = ufs_rw16(ep->d_reclen, needswap);
+                               results->ulr_reclen =
+                                   ufs_rw16(ep->d_reclen, needswap);
                                goto found;
                        }
                }
@@ -431,8 +441,8 @@
         */
        if ((nameiop == CREATE || nameiop == RENAME ||
             (nameiop == DELETE &&
-             (ap->a_cnp->cn_flags & DOWHITEOUT) &&
-             (ap->a_cnp->cn_flags & ISWHITEOUT))) &&
+             (cnp->cn_flags & DOWHITEOUT) &&
+             (cnp->cn_flags & ISWHITEOUT))) &&
            (flags & ISLASTCN) && dp->i_nlink != 0) {
                /*
                 * Access for write is interpreted as allowing
@@ -459,7 +469,8 @@
                        if ((results->ulr_offset & (dirblksiz - 1)) == 0)
                                results->ulr_count = 0;
                        else
-                               results->ulr_count = results->ulr_offset - prevoff;
+                               results->ulr_count =
+                                   results->ulr_offset - prevoff;
                } else {
                        results->ulr_offset = slotoffset;
                        results->ulr_count = slotsize;
@@ -501,7 +512,8 @@
         */
        if (results->ulr_offset + DIRSIZ(FSFMT(vdp), ep, needswap) > dp->i_size) {
                ufs_dirbad(dp, results->ulr_offset, "i_size too small");
-               dp->i_size = results->ulr_offset + DIRSIZ(FSFMT(vdp), ep, needswap);
+               dp->i_size =
+                   results->ulr_offset + DIRSIZ(FSFMT(vdp), ep, needswap);
                DIP_ASSIGN(dp, size, dp->i_size);
                dp->i_flag |= IN_CHANGE | IN_UPDATE;
                UFS_WAPBL_UPDATE(vdp, NULL, NULL, UPDATE_DIROP);
@@ -901,7 +913,7 @@
         * dp->i_offset + dp->i_count would yield the space.
         */
        ep = (struct direct *)dirbuf;
-       dsize = (ep->d_ino != 0) ?  DIRSIZ(FSFMT(dvp), ep, needswap) : 0;
+       dsize = (ep->d_ino != 0) ? DIRSIZ(FSFMT(dvp), ep, needswap) : 0;
        spacefree = ufs_rw16(ep->d_reclen, needswap) - dsize;
        for (loc = ufs_rw16(ep->d_reclen, needswap); loc < ulr->ulr_count; ) {
                uint16_t reclen;
@@ -1446,7 +1458,7 @@
 
 /*
  * ufs_blkatoff: Return buffer with the contents of block "offset" from
- * the beginning of directory "vp".  If "res" is non-zero, fill it in with
+ * the beginning of directory "vp".  If "res" is non-NULL, fill it in with
  * a pointer to the remaining space in the directory.  If the caller intends
  * to modify the buffer returned, "modify" must be true.
  */



Home | Main Index | Thread Index | Old Index