Subject: mfs on netbsd
To: None <current-users@netbsd.org>
From: Srinivasa Kanduru <ksraghavan@yahoo.com>
List: current-users
Date: 11/03/2004 13:22:13
Hi,

I was trying to build a memory-based  filesystem and encountered certain
issues. I thought of bringing it to the notice of the group.



 diff -u uvm_map.c.orig uvm_map.c
--- uvm_map.c.orig      2004-11-03 19:50:22.000000000 -0800
+++ uvm_map.c   2004-10-29 22:02:19.000000000 -0700
@@ -1397,7 +1397,8 @@
         * it, there would be four cases).
         */

-       if ((flags & UVM_FLAG_FIXED) == 0 && hint == map->min_offset) {
+       if (((flags & UVM_FLAG_FIXED) == 0 && hint == map->min_offset) ||
+           (&map->header == map->header.next && &map->header ==
map->header.prev)) {
                entry = map->first_free;

        } else {

... since after map setup prev, next and hint point to the header.

 diff -u ufs_bmap.c.orig ufs_bmap.c
--- ufs_bmap.c.orig     2004-11-03 16:35:19.000000000 -0800
+++ ufs_bmap.c  2004-11-03 16:35:26.000000000 -0800
@@ -308,7 +308,7 @@
 {
        daddr_t metalbn, realbn;
        struct ufsmount *ump;
-       int64_t blockcnt;
+       int64_t blockcnt = 0;
        int lbc;
        int i, numlevels, off;


... lbn calculation might not be right without initialization of blockcnt ..

I am not sure if the below changes are needed &/or sufficient for ffs_read(). I
tried to follow what other xxx_read() are doing to trigger off xxx_strategy()
which may be required on the first read of a file.

But ubc_alloc() sets PGO_OVERWRITE bit which prevents the strategy from being
called.

Has mfs been tested on netbsd ? 

 diff -u ufs_readwrite.c.orig ufs_readwrite.c
--- ufs_readwrite.c.orig        2004-11-03 19:59:57.000000000 -0800
+++ ufs_readwrite.c     2004-11-03 20:00:27.000000000 -0800
@@ -79,6 +79,7 @@
        long size, xfersize, blkoffset;
        int error;
        boolean_t usepc = FALSE;
+       int extending = 0;

        vp = ap->a_vp;
        ip = VTOI(vp);
@@ -117,9 +118,11 @@
                            uio->uio_resid);
                        if (bytelen == 0)
                                break;
+                       extending = ((uio->uio_offset & PAGE_MASK) == 0);

                        win = ubc_alloc(&vp->v_uobj, uio->uio_offset,
-                                       &bytelen, UBC_READ);
+                                       &bytelen, extending ?
+                                       UBC_READ|UBC_FAULTBUSY : UBC_READ);
                        error = uiomove(win, bytelen, uio);
                        ubc_release(win, 0);
                        if (error)


Thanks,
Srini.


		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com