Author: avg
Date: Thu Feb 26 12:33:22 2009
New Revision: 189070
URL: http://svn.freebsd.org/changeset/base/189070

Log:
  udf: add read-ahead support modeled after cd9660
  
  Reviewed by: scottl
  Approved by: jhb (mentor)

Modified:
  head/sys/fs/udf/udf_vfsops.c
  head/sys/fs/udf/udf_vnops.c

Modified: head/sys/fs/udf/udf_vfsops.c
==============================================================================
--- head/sys/fs/udf/udf_vfsops.c        Thu Feb 26 12:33:17 2009        
(r189069)
+++ head/sys/fs/udf/udf_vfsops.c        Thu Feb 26 12:33:22 2009        
(r189070)
@@ -334,6 +334,11 @@ udf_mountfs(struct vnode *devvp, struct 
 
        bo = &devvp->v_bufobj;
 
+       if (devvp->v_rdev->si_iosize_max != 0)
+               mp->mnt_iosize_max = devvp->v_rdev->si_iosize_max;
+       if (mp->mnt_iosize_max > MAXPHYS)
+               mp->mnt_iosize_max = MAXPHYS;
+
        /* XXX: should be M_WAITOK */
        udfmp = malloc(sizeof(struct udf_mnt), M_UDFMOUNT,
            M_NOWAIT | M_ZERO);

Modified: head/sys/fs/udf/udf_vnops.c
==============================================================================
--- head/sys/fs/udf/udf_vnops.c Thu Feb 26 12:33:17 2009        (r189069)
+++ head/sys/fs/udf/udf_vnops.c Thu Feb 26 12:33:22 2009        (r189070)
@@ -1045,6 +1045,7 @@ udf_bmap(struct vop_bmap_args *a)
        struct udf_node *node;
        uint32_t max_size;
        daddr_t lsector;
+       int nblk;
        int error;
 
        node = VTON(a->a_vp);
@@ -1075,9 +1076,23 @@ udf_bmap(struct vop_bmap_args *a)
        /* Translate logical to physical sector number */
        *a->a_bnp = lsector << (node->udfmp->bshift - DEV_BSHIFT);
 
-       /* Punt on read-ahead for now */
-       if (a->a_runp)
-               *a->a_runp = 0;
+       /*
+        * Determine maximum number of readahead blocks following the
+        * requested block.
+        */
+       if (a->a_runp) {
+               nblk = (max_size >> node->udfmp->bshift) - 1;
+               if (nblk <= 0)
+                       *a->a_runp = 0;
+               else if (nblk >= (MAXBSIZE >> node->udfmp->bshift))
+                       *a->a_runp = (MAXBSIZE >> node->udfmp->bshift) - 1;
+               else
+                       *a->a_runp = nblk;
+       }
+
+       if (a->a_runb) {
+               *a->a_runb = 0;
+       }
 
        return (0);
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to