Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Jan 2003 19:22:49 +0100 (CET)
From:      Tomas Pluskal <plusik@pohoda.cz>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        Terry Lambert <tlambert2@mindspring.com>, <freebsd-fs@FreeBSD.ORG>
Subject:   Re: seeking help to rewrite the msdos filesystem
Message-ID:  <20030111191832.B18312-200000@localhost.localdomain>
In-Reply-To: <20021114020947.O6495-100000@gamplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]

Hello,

I have made a simple patch to enable clustering in msdosfs.
It is against 4-STABLE.

With this patch I get speed on my ZIP drive about 700KB/s (while before it
was about 80KB/s).

Could please someone review it ?

Thanks

Tomas

On Thu, 14 Nov 2002, Bruce Evans wrote:

> On Wed, 13 Nov 2002, Tomas Pluskal wrote:
>
> > > ...  Clustering increases the
> > > effective block size to 64K, which is large enough for most purposes,
> > > but mdosfs is missing the few lines of code needed to implement
> > > clustering...
> >
> > Could you please write a liitle more about those "missing few
> > lines of code" ? I think it is what I could do and what would help when
> > using ZIP drives and digital cameras etc..
>
> "grep -i cluster *.c" in code for other file systems.  cd9660 is simplest --
> it just has one cluster_read() instead of a bread().
>
> Bruce
>
>


[-- Attachment #2 --]
--- msdosfs_vnops.c.old	Sat Jan 11 18:58:28 2003
+++ msdosfs_vnops.c	Sat Jan 11 18:58:33 2003
@@ -606,14 +606,24 @@
 		} else {
 			blsize = pmp->pm_bpcluster;
 			rablock = lbn + 1;
-			if (seqcount > 1 &&
-			    de_cn2off(pmp, rablock) < dep->de_FileSize) {
-				rasize = pmp->pm_bpcluster;
-				error = breadn(vp, lbn, blsize,
-				    &rablock, &rasize, 1, NOCRED, &bp); 
-			} else {
-				error = bread(vp, lbn, blsize, NOCRED, &bp);
-			}
+                        if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) {
+        			if (de_cn2off(pmp, rablock) < dep->de_FileSize) {
+                                    error = cluster_read(vp, (off_t)dep->de_FileSize,
+                                            lbn, blsize, NOCRED, uio->uio_resid,
+                                            seqcount ,&bp);
+                                } else 
+                                        error = bread(vp, lbn, blsize, NOCRED, &bp);
+                                
+                        } else {
+				if (seqcount > 1 &&
+				    de_cn2off(pmp, rablock) < dep->de_FileSize) {
+					rasize = pmp->pm_bpcluster;
+					error = breadn(vp, lbn, blsize,
+						       &rablock, &rasize, 1, NOCRED, &bp); 
+				} else {
+					error = bread(vp, lbn, blsize, NOCRED, &bp);
+	    			}
+                        }
 		}
 		if (error) {
 			brelse(bp);
@@ -665,6 +675,7 @@
 	struct denode *dep = VTODE(vp);
 	struct msdosfsmount *pmp = dep->de_pmp;
 	struct ucred *cred = ap->a_cred;
+        int seqcount = ap->a_ioflag >> 16;
 
 #ifdef MSDOSFS_DEBUG
 	printf("msdosfs_write(vp %p, uio %p, ioflag %x, cred %p\n",
@@ -812,10 +823,17 @@
 		 */
 		if (ioflag & IO_SYNC)
 			(void) bwrite(bp);
-		else if (n + croffset == pmp->pm_bpcluster)
-			bawrite(bp);
-		else
+		else if (n + croffset == pmp->pm_bpcluster) {
+                        if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) {
+                                bp->b_flags |= B_CLUSTEROK;
+                                cluster_write(bp, dep->de_FileSize, seqcount);
+                        } else {    
+        			bawrite(bp);
+                        }
+		} else {
+                        bp->b_flags |= B_CLUSTEROK;
 			bdwrite(bp);
+                }
 		dep->de_flag |= DE_UPDATE;
 	} while (error == 0 && uio->uio_resid > 0);
 
@@ -1804,16 +1822,24 @@
 	} */ *ap;
 {
 	struct denode *dep = VTODE(ap->a_vp);
+        struct msdosfsmount *pmp = dep->de_pmp;
+        daddr_t lblkno = ap->a_bn;
+	int bshift = pmp->pm_bnshift;
 
 	if (ap->a_vpp != NULL)
 		*ap->a_vpp = dep->de_devvp;
 	if (ap->a_bnp == NULL)
 		return (0);
 	if (ap->a_runp) {
-		/*
-		 * Sequential clusters should be counted here.
-		 */
-		*ap->a_runp = 0;
+		int nblk;
+
+		nblk = (dep->de_FileSize >> bshift) - (lblkno + 1);
+		if (nblk <= 0)
+			*ap->a_runp = 0;
+		else if (nblk >= (MAXBSIZE >> bshift))
+			*ap->a_runp = (MAXBSIZE >> bshift) - 1;
+		else
+			*ap->a_runp = nblk;
 	}
 	if (ap->a_runb) {
 		*ap->a_runb = 0;

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030111191832.B18312-200000>