[Pvfs2-cvs] commit by slang in pvfs2/src/kernel/linux-2.6: file.c
pvfs2-bufmap.c
CVS commit program
cvs at parl.clemson.edu
Tue Jan 9 02:20:41 EST 2007
Update of /projects/cvsroot/pvfs2/src/kernel/linux-2.6
In directory parlweb1:/tmp/cvs-serv10278/src/kernel/linux-2.6
Modified Files:
Tag: pvfs-2-6-branch
file.c pvfs2-bufmap.c
Log Message:
commit Murali's fix. See: http://www.beowulf-underground.org/pipermail/pvfs2-users/2007-January/001692.html
Index: file.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/file.c,v
diff -p -u -r1.129.8.7 -r1.129.8.8
--- file.c 5 Dec 2006 21:37:46 -0000 1.129.8.7
+++ file.c 9 Jan 2007 07:20:41 -0000 1.129.8.8
@@ -350,37 +350,33 @@ static int split_iovecs(
*seg_count = 0;
*seg_array = NULL;
/* copy the passed in iovec descriptor to a temp structure */
- orig_iovec = (struct iovec *) kmalloc(nr_segs * sizeof(struct 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",
- (unsigned long)(nr_segs * sizeof(struct iovec)));
+ (unsigned long)(nr_segs * sizeof(*orig_iovec)));
return -ENOMEM;
}
- new_iovec = (struct iovec *) kmalloc(max_new_nr_segs * sizeof(struct iovec),
+ new_iovec = kzalloc(max_new_nr_segs * sizeof(*new_iovec),
PVFS2_BUFMAP_GFP_FLAGS);
if (new_iovec == NULL)
{
kfree(orig_iovec);
gossip_err("split_iovecs: Could not allocate memory for %lu bytes!\n",
- (unsigned long)(max_new_nr_segs * sizeof(struct iovec)));
+ (unsigned long)(max_new_nr_segs * sizeof(*new_iovec)));
return -ENOMEM;
}
- sizes = (unsigned long *) kmalloc(max_new_nr_segs * sizeof(unsigned long),
- PVFS2_BUFMAP_GFP_FLAGS);
+ sizes = kzalloc(max_new_nr_segs * sizeof(*sizes), PVFS2_BUFMAP_GFP_FLAGS);
if (sizes == NULL)
{
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(int)));
+ (unsigned long)(max_new_nr_segs * sizeof(*sizes)));
return -ENOMEM;
}
/* copy the passed in iovec to a temp structure */
- memcpy(orig_iovec, original_iovec, nr_segs * sizeof(struct iovec));
- memset(new_iovec, 0, max_new_nr_segs * sizeof(struct iovec));
- memset(sizes, 0, max_new_nr_segs * sizeof(int));
+ memcpy(orig_iovec, original_iovec, nr_segs * sizeof(*orig_iovec));
begin_seg = 0;
repeat:
for (seg = begin_seg; seg < nr_segs; seg++)
@@ -911,37 +907,33 @@ static int split_xtvecs(
*seg_count = 0;
*seg_array = NULL;
/* copy the passed in xtvec descriptor to a temp structure */
- orig_xtvec = (struct xtvec *) kmalloc(nr_segs * sizeof(struct xtvec),
- PVFS2_BUFMAP_GFP_FLAGS);
+ orig_xtvec = kmalloc(nr_segs * sizeof(*orig_xtvec), PVFS2_BUFMAP_GFP_FLAGS);
if (orig_xtvec == NULL)
{
gossip_err("split_xtvecs: Could not allocate memory for %lu bytes!\n",
- (unsigned long)(nr_segs * sizeof(struct xtvec)));
+ (unsigned long)(nr_segs * sizeof(*orig_xtvec)));
return -ENOMEM;
}
- new_xtvec = (struct xtvec *) kmalloc(max_new_nr_segs * sizeof(struct xtvec),
+ new_xtvec = kzalloc(max_new_nr_segs * sizeof(*new_xtvec),
PVFS2_BUFMAP_GFP_FLAGS);
if (new_xtvec == NULL)
{
kfree(orig_xtvec);
gossip_err("split_xtvecs: Could not allocate memory for %lu bytes!\n",
- (unsigned long)(max_new_nr_segs * sizeof(struct xtvec)));
+ (unsigned long)(max_new_nr_segs * sizeof(*new_xtvec)));
return -ENOMEM;
}
- sizes = (unsigned long *) kmalloc(max_new_nr_segs * sizeof(unsigned long),
- PVFS2_BUFMAP_GFP_FLAGS);
+ sizes = kzalloc(max_new_nr_segs * sizeof(*sizes), PVFS2_BUFMAP_GFP_FLAGS);
if (sizes == NULL)
{
kfree(new_xtvec);
kfree(orig_xtvec);
gossip_err("split_xtvecs: Could not allocate memory for %lu bytes!\n",
- (unsigned long)(max_new_nr_segs * sizeof(int)));
+ (unsigned long)(max_new_nr_segs * sizeof(*sizes)));
return -ENOMEM;
}
/* copy the passed in xtvec to a temp structure */
- memcpy(orig_xtvec, original_xtvec, nr_segs * sizeof(struct xtvec));
- memset(new_xtvec, 0, max_new_nr_segs * sizeof(struct xtvec));
- memset(sizes, 0, max_new_nr_segs * sizeof(int));
+ memcpy(orig_xtvec, original_xtvec, nr_segs * sizeof(*orig_xtvec));
begin_seg = 0;
count = 0;
tmpnew_nr_segs = 0;
Index: pvfs2-bufmap.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/pvfs2-bufmap.c,v
diff -p -u -r1.46.8.3 -r1.46.8.4
--- pvfs2-bufmap.c 6 Dec 2006 00:10:57 -0000 1.46.8.3
+++ pvfs2-bufmap.c 9 Jan 2007 07:20:41 -0000 1.46.8.4
@@ -50,19 +50,16 @@ 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",
More information about the Pvfs2-cvs
mailing list