Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Jul 2011 16:25:25 GMT
From:      Ilya Putsikau <ilya@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 195716 for review
Message-ID:  <201107041625.p64GPPve047598@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@195716?ac=10

Change 195716 by ilya@ilya_triton2011 on 2011/07/04 16:25:24

	Add fuse_vnode_setsize function

Affected files ...

.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse.h#11 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_io.c#13 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_node.c#12 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_node.h#12 edit
.. //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_vnops.c#32 edit

Differences ...

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse.h#11 (text+ko) ====

@@ -80,15 +80,6 @@
 #endif
 #endif
 
-#ifndef FUSELIB_CONFORM_BIOREAD
-/* 
- * make BIO behave as it's prescribed in fuselib's fuse.h,
- * ie. in case of buffered reading, short reads instruct
- * the kernel to fill the rest of the buffer with zeroes 
- */
-#define FUSELIB_CONFORM_BIOREAD 1
-#endif
-
 /* misc */
 
 extern int fuse_useco;

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_io.c#13 (text+ko) ====

@@ -492,7 +492,7 @@
     daddr_t lbn;
     int bcount;
     int n, on, err = 0;
-    vm_ooffset_t fsize = vp->v_object->un_pager.vnp.vnp_size;
+    off_t fsize = VTOFUD(vp)->filesize;
 
     DEBUG2G("fsize %lld\n", (long long int)fsize); 
 
@@ -535,7 +535,7 @@
                 long save;
 
                 fsize = uio->uio_offset + n;
-                vnode_pager_setsize(vp, fsize);
+		fuse_vnode_setsize(vp, fsize);
 
                 save = bp->b_flags & B_CACHE;
                 bcount += n;
@@ -558,7 +558,7 @@
             bp = getblk(vp, lbn, bcount, PCATCH, 0, 0);
             if (uio->uio_offset + n > fsize) {
                 fsize = uio->uio_offset + n;
-                vnode_pager_setsize(vp, fsize);
+                fuse_vnode_setsize(vp, fsize);
             }
         }
 
@@ -701,6 +701,7 @@
 fuse_io_strategy(struct vnode *vp, struct buf *bp, struct fuse_filehandle *fufh,
     enum fuse_opcode op)
 {
+    struct fuse_vnode_data *fvdat = VTOFUD(vp);
     struct fuse_dispatcher fdi;
     struct ucred *cred; 
     int err = 0;
@@ -751,13 +752,7 @@
     if (bp->b_iocmd == BIO_READ) {
         struct fuse_read_in *fri;
         int ioff = 0;
-#if FUSELIB_CONFORM_BIOREAD
-        struct vattr va;
 
-        if ((err = VOP_GETATTR(vp, &va, cred)))
-            goto out;
-#endif
-
         bufdat = bp->b_data;
         bp->b_resid = bp->b_bcount;
         while (bp->b_resid > 0) {
@@ -772,15 +767,13 @@
             fri = fdi.indata;
             fri->fh = fufh->fh_id;
             fri->offset = ((off_t)bp->b_blkno) * biosize + ioff;
-#if FUSELIB_CONFORM_BIOREAD
             chunksize = MIN(chunksize,
                 MIN(fri->offset + bp->b_resid,
-                va.va_size) - fri->offset);
+                fvdat->filesize) - fri->offset);
             if (chunksize == 0) {
                 respsize = -1;
                 goto eval;
             }
-#endif
             fri->size = chunksize;
             fdi.tick->tk_aw_type = FT_A_BUF;
             fdi.tick->tk_aw_bufdata = bufdat;
@@ -796,9 +789,7 @@
             bufdat += respsize;
             ioff += respsize;
 
-#if FUSELIB_CONFORM_BIOREAD
 eval:
-#endif
             DEBUG2G("%d bytes asked for from offset %llu, passing on the %d we got\n",
                 chunksize, (long long unsigned)fri->offset, respsize);
 
@@ -811,10 +802,8 @@
                     bp->b_resid);
                 bzero((char *)bp->b_data + bp->b_bcount - bp->b_resid,
                     bp->b_resid);
-#if FUSELIB_CONFORM_BIOREAD
                 if (chunksize)
                     bp->b_resid = 0;
-#endif
                 break;
             }
             if (respsize > chunksize) {

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_node.c#12 (text+ko) ====

@@ -25,15 +25,16 @@
 #include <sys/sysctl.h>
 #include <sys/fcntl.h>
 #include <sys/fnv_hash.h>
+#include <sys/priv.h>
+#include <security/mac/mac_framework.h>
+#include <vm/vm.h>
+#include <vm/vm_extern.h>
 
 #include "fuse.h"
 #include "fuse_node.h"
 #include "fuse_internal.h"
 #include "fuse_ipc.h"
 
-#include <sys/priv.h>
-#include <security/mac/mac_framework.h>
-
 #define FUSE_DEBUG_MODULE VNOPS
 #include "fuse_debug.h"
 
@@ -212,3 +213,12 @@
         vnode_create_vobject(vp, 0, td);
     }
 }
+
+void
+fuse_vnode_setsize(struct vnode *vp, off_t newsize)
+{
+    struct fuse_vnode_data *fvdat = VTOFUD(vp);
+
+    vnode_pager_setsize(vp, newsize);
+    fvdat->filesize = newsize;
+}

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_node.h#12 (text+ko) ====

@@ -109,17 +109,18 @@
 
 void fuse_vnode_destroy(struct vnode *vp);
 
-int
-fuse_vnode_get(struct mount         *mp,
-               uint64_t              nodeid,
-               struct vnode         *dvp,
-               struct vnode        **vpp,
-               struct componentname *cnp,
-               enum vtype            vtyp,
-               uint64_t              size);
+int fuse_vnode_get(struct mount         *mp,
+                   uint64_t              nodeid,
+                   struct vnode         *dvp,
+                   struct vnode        **vpp,
+                   struct componentname *cnp,
+                   enum vtype            vtyp,
+                   uint64_t              size);
 
 void fuse_vnode_open(struct vnode *vp,
                      int32_t fuse_open_flags,
                      struct thread *td);
 
+void fuse_vnode_setsize(struct vnode *vp, off_t newsize);
+
 #endif /* _FUSE_NODE_H_ */

==== //depot/projects/soc2011/ilya_fuse/fuse_module/fuse_vnops.c#32 (text+ko) ====

@@ -508,8 +508,7 @@
         off_t new_filesize = ((struct fuse_attr_out *)fdi.answ)->attr.size;
 
         if (fvdat->filesize != new_filesize) {
-            fvdat->filesize = new_filesize;
-            vnode_pager_setsize(vp, new_filesize);
+            fuse_vnode_setsize(vp, new_filesize);
         }
     }
 
@@ -1724,8 +1723,7 @@
     fuse_ticket_drop(fdi.tick);
     if (!err && sizechanged) {
         fuse_invalidate_attr(vp);
-        VTOFUD(vp)->filesize = newsize;
-        vnode_pager_setsize(vp, newsize);
+        fuse_vnode_setsize(vp, newsize);
     }
 
     return err;



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