Author: pjd
Date: Tue Mar  8 18:39:41 2011
New Revision: 219404
URL: http://svn.freebsd.org/changeset/base/219404

Log:
  Correct readdir over ZFS handling.
  
  Reported by:  Pierre Beyssac <[email protected]>
  MFC after:    1 month

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c     Tue Mar 
 8 17:43:35 2011        (r219403)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c     Tue Mar 
 8 18:39:41 2011        (r219404)
@@ -2394,7 +2394,8 @@ zfs_readdir(vnode_t *vp, uio_t *uio, cre
                 * Minimum entry size is dirent size and 1 byte for a file name.
                 */
                ncooks = uio->uio_resid / (sizeof(struct dirent) - 
sizeof(((struct dirent *)NULL)->d_name) + 1);
-               *cookies = malloc(ncooks * sizeof(u_long), M_TEMP, M_WAITOK);
+               cooks = malloc(ncooks * sizeof(u_long), M_TEMP, M_WAITOK);
+               *cookies = cooks;
                *ncookies = ncooks;
        }
        /*
@@ -2541,16 +2542,6 @@ zfs_readdir(vnode_t *vp, uio_t *uio, cre
                if (prefetch)
                        dmu_prefetch(os, objnum, 0, 0);
 
-               if (ncookies != NULL) {
-                       if (cooks == NULL)
-                               cooks = *cookies;
-                       else {
-                               *cooks++ = offset;
-                               ncooks--;
-                               KASSERT(ncooks >= 0, ("ncookies=%d", ncooks));
-                       }
-               }
-
        skip_entry:
                /*
                 * Move to the next entry, fill in the previous offset.
@@ -2561,6 +2552,12 @@ zfs_readdir(vnode_t *vp, uio_t *uio, cre
                } else {
                        offset += 1;
                }
+
+               if (cooks != NULL) {
+                       *cooks++ = offset;
+                       ncooks--;
+                       KASSERT(ncooks >= 0, ("ncookies=%d", ncooks));
+               }
        }
        zp->z_zn_prefetch = B_FALSE; /* a lookup will re-enable pre-fetching */
 
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to