[Pvfs2-cvs] commit by slang in pvfs2/src/kernel/linux-2.6: devpvfs2-req.c file.c pvfs2-bufmap.c pvfs2-cache.c

CVS commit program cvs at parl.clemson.edu
Thu Feb 1 21:09:01 EST 2007


Update of /projects/cvsroot/pvfs2/src/kernel/linux-2.6
In directory parlweb1:/tmp/cvs-serv3158/src/kernel/linux-2.6

Modified Files:
	devpvfs2-req.c file.c pvfs2-bufmap.c pvfs2-cache.c 
Log Message:
merge 2.6 branch changes to head


Index: devpvfs2-req.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/devpvfs2-req.c,v
diff -p -u -r1.68 -r1.69
--- devpvfs2-req.c	4 Dec 2006 06:18:25 -0000	1.68
+++ devpvfs2-req.c	2 Feb 2007 02:09:00 -0000	1.69
@@ -232,11 +232,17 @@ static ssize_t pvfs2_devreq_read(
     return len;
 }
 
-static ssize_t pvfs2_devreq_writev(
-    struct file *file,
-    const struct iovec *iov,
-    unsigned long count,
-    loff_t * offset)
+struct devrw_options {
+    struct file   *file;
+    /* Asynch I/O control block */
+    struct kiocb *iocb;
+    struct iovec *iov;
+    unsigned long nr_segs;
+    loff_t        *offset;
+};
+
+/* Common function for writev() and aio_write() callers into the device */
+static ssize_t do_devreq_writev(struct devrw_options *rw)
 {
     pvfs2_kernel_op_t *op = NULL;
     struct qhash_head *hash_link = NULL;
@@ -250,12 +256,18 @@ static ssize_t pvfs2_devreq_writev(
     int32_t magic = 0;
     int32_t proto_ver = 0;
     uint64_t tag = 0;
+    struct iovec *iov = NULL;
+    ssize_t total_returned_size = 0;
 
+    if (!rw || ((iov = rw->iov) == NULL)) {
+        gossip_err("Error: invalid parameter to device vectored write\n");
+        return -EINVAL;
+    }
     /* Either there is a trailer or there isn't */
-    if (count != notrailer_count && count != (notrailer_count + 1))
+    if (rw->nr_segs != notrailer_count && rw->nr_segs != (notrailer_count + 1))
     {
         gossip_err("Error: Number of iov vectors is (%ld) and notrailer count is %d\n",
-                count, notrailer_count);
+                rw->nr_segs, notrailer_count);
         return -EPROTO;
     }
     buffer = dev_req_alloc();
@@ -284,6 +296,7 @@ static ssize_t pvfs2_devreq_writev(
 	ptr += iov[i].iov_len;
 	payload_size += iov[i].iov_len;
     }
+    total_returned_size = payload_size;
 
     /* these elements are currently 8 byte aligned (8 bytes for (version +  
      * magic) 8 bytes for tag).  If you add another element, either make it 8
@@ -338,10 +351,10 @@ static ssize_t pvfs2_devreq_writev(
             if (op->downcall.status == 0 && op->downcall.trailer_size > 0)
             {
                 gossip_debug(GOSSIP_DEV_DEBUG, "writev: trailer size %ld\n", (unsigned long) op->downcall.trailer_size);
-                if (count != (notrailer_count + 1))
+                if (rw->nr_segs != (notrailer_count + 1))
                 {
                     gossip_err("Error: trailer size (%ld) is non-zero, no trailer elements though? (%ld)\n",
-                            (unsigned long) op->downcall.trailer_size, count);
+                            (unsigned long) op->downcall.trailer_size, rw->nr_segs);
                     dev_req_release(buffer);
                     put_op(op);
                     return -EPROTO;
@@ -541,8 +554,61 @@ static ssize_t pvfs2_devreq_writev(
     }
     dev_req_release(buffer);
 
-    return count;
+    /* if we are called from aio context, just mark that the iocb is completed */
+    if (rw->iocb) {
+        aio_complete(rw->iocb, total_returned_size, 0);
+    }
+
+    return total_returned_size;
+}
+
+#ifdef HAVE_WRITEV_FILE_OPERATIONS
+static ssize_t pvfs2_devreq_writev(
+    struct file *file,
+    const struct iovec *iov,
+    unsigned long n_segs,
+    loff_t * offset)
+{
+    struct devrw_options rw;
+
+    memset(&rw, 0, sizeof(rw));
+    rw.iocb = NULL;
+    rw.iov = (struct iovec *) iov;
+    rw.nr_segs = n_segs;
+    rw.offset = offset;
+    return do_devreq_writev(&rw);
 }
+#endif
+
+#ifdef HAVE_AIO_NEW_AIO_SIGNATURE
+/* For simplicity I am going to treat this aio call as if it were synchronous */
+static ssize_t
+pvfs2_devreq_aio_write(struct kiocb *iocb, const struct iovec *iov,
+        unsigned long n_segs, loff_t offset)
+{
+    struct devrw_options rw;
+
+    memset(&rw, 0, sizeof(rw));
+    rw.file = iocb->ki_filp;
+    rw.iov  = (struct iovec *) iov;
+    rw.nr_segs = n_segs;
+    rw.offset = &offset;
+    return do_devreq_writev(&rw);
+}
+
+#endif
+
+#ifdef HAVE_COMBINED_AIO_AND_VECTOR
+/*
+ * Kernels >= 2.6.19 have no writev, use this instead with SYNC_KEY.
+ */
+static ssize_t pvfs2_devreq_aio_write(struct kiocb *kiocb,
+                                      const struct iovec *iov,
+                                      unsigned long count, loff_t offset)
+{
+    return pvfs2_devreq_writev(kiocb->ki_filp, iov, count, &kiocb->ki_pos);
+}
+#endif
 
 #ifdef HAVE_COMBINED_AIO_AND_VECTOR
 /*
@@ -1020,7 +1086,9 @@ struct file_operations pvfs2_devreq_file
 #ifdef PVFS2_LINUX_KERNEL_2_4
     owner: THIS_MODULE,
     read : pvfs2_devreq_read,
+#ifdef HAVE_WRITEV_FILE_OPERATIONS
     writev : pvfs2_devreq_writev,
+#endif
     open : pvfs2_devreq_open,
     release : pvfs2_devreq_release,
     ioctl : pvfs2_devreq_ioctl,

Index: file.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/file.c,v
diff -p -u -r1.135 -r1.136
--- file.c	9 Jan 2007 07:23:57 -0000	1.135
+++ file.c	2 Feb 2007 02:09:00 -0000	1.136
@@ -350,7 +350,7 @@ static int split_iovecs(
     *seg_count = 0;
     *seg_array = NULL;
     /* copy the passed in iovec descriptor to a temp structure */
-    orig_iovec = kzalloc(nr_segs * sizeof(*orig_iovec), PVFS2_BUFMAP_GFP_FLAGS);
+    orig_iovec = kmalloc(nr_segs * sizeof(*orig_iovec), PVFS2_BUFMAP_GFP_FLAGS);
     if (orig_iovec == NULL)
     {
         gossip_err("split_iovecs: Could not allocate memory for %lu bytes!\n", 
@@ -372,7 +372,7 @@ static int split_iovecs(
         kfree(new_iovec);
         kfree(orig_iovec);
         gossip_err("split_iovecs: Could not allocate memory for %lu bytes!\n", 
-                (unsigned long)(max_new_nr_segs * sizeof(unsigned long)));
+                (unsigned long)(max_new_nr_segs * sizeof(*sizes)));
         return -ENOMEM;
     }
     /* copy the passed in iovec to a temp structure */

Index: pvfs2-bufmap.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/pvfs2-bufmap.c,v
diff -p -u -r1.49 -r1.50
--- pvfs2-bufmap.c	5 Dec 2006 23:21:25 -0000	1.49
+++ pvfs2-bufmap.c	2 Feb 2007 02:09:00 -0000	1.50
@@ -50,23 +50,20 @@ static int initialize_bufmap_descriptors
         goto out;
     }
     err = -ENOMEM;
-    buffer_index_array = (int *) kmalloc(ndescs * sizeof(int), 
-                                         PVFS2_BUFMAP_GFP_FLAGS);
+    buffer_index_array = kzalloc(ndescs * sizeof(*buffer_index_array), 
+                                 PVFS2_BUFMAP_GFP_FLAGS);
     if (buffer_index_array == NULL) 
     {
         gossip_err("pvfs2: could not allocate %d bytes\n",
-                (int) (ndescs * sizeof(int)));
+                (int) (ndescs * sizeof(*buffer_index_array)));
         goto out;
     }
-    memset(buffer_index_array, 0, ndescs * sizeof(int));
 
-    desc_array = (struct pvfs_bufmap_desc *) 
-                 kmalloc(ndescs * sizeof(struct pvfs_bufmap_desc),
-                         PVFS2_BUFMAP_GFP_FLAGS);
+    desc_array = kmalloc(ndescs * sizeof(*desc_array), PVFS2_BUFMAP_GFP_FLAGS);
     if (desc_array == NULL)
     {
         gossip_err("pvfs2: could not allocate %d bytes\n",
-                (int) (ndescs * sizeof(struct pvfs_bufmap_desc)));
+                ndescs * sizeof(struct pvfs_bufmap_desc));
         goto out1;
     }
     err = 0;

Index: pvfs2-cache.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/pvfs2-cache.c,v
diff -p -u -r1.38 -r1.39
--- pvfs2-cache.c	22 Jan 2007 22:48:36 -0000	1.38
+++ pvfs2-cache.c	2 Feb 2007 02:09:00 -0000	1.39
@@ -44,6 +44,17 @@ static int pvfs_kmem_cache_destroy(void 
 }
 #endif
 
+#ifdef HAVE_KMEM_CACHE_DESTROY_INT_RETURN
+#define pvfs_kmem_cache_destroy kmem_cache_destroy
+#else
+/* recent kernels do not return a value */
+static int pvfs_kmem_cache_destroy(void *x)
+{
+    kmem_cache_destroy(x);
+    return 0;
+}
+#endif
+
 int op_cache_initialize(void)
 {
     op_cache = kmem_cache_create(



More information about the Pvfs2-cvs mailing list