diff mbox

SQUASHME: objio read/write patch: Bugs fixes

Message ID 4DDAB94C.6070407@panasas.com (mailing list archive)
State New, archived
Headers show

Commit Message

Boaz Harrosh May 23, 2011, 7:45 p.m. UTC
Wrong allocation and pointering in lseg_alloc.

Cap BIO size it one page (This hunk goes into the read/write patch)

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 fs/nfs/objlayout/objio_osd.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

Comments

Benny Halevy May 24, 2011, 1:10 p.m. UTC | #1
On 2011-05-23 22:45, Boaz Harrosh wrote:
> 
> Wrong allocation and pointering in lseg_alloc.
> 
> Cap BIO size it one page (This hunk goes into the read/write patch)
> 
> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
> ---
>  fs/nfs/objlayout/objio_osd.c |   12 ++++++++----
>  1 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c
> index 9bb5830..b6ec124 100644
> --- a/fs/nfs/objlayout/objio_osd.c
> +++ b/fs/nfs/objlayout/objio_osd.c
> @@ -147,7 +147,7 @@ struct objio_segment {
>  	unsigned comps_index;
>  	unsigned num_comps;
>  	/* variable length */
> -	struct osd_dev	*ods[1];
> +	struct osd_dev	*ods[];
>  };
>  
>  static inline struct objio_segment *
> @@ -331,7 +331,6 @@ extern int objio_alloc_lseg(struct pnfs_layout_segment **outp,
>  	struct pnfs_osd_layout layout;
>  	struct pnfs_osd_object_cred *cur_comp, src_comp;
>  	struct caps_buffers *caps_p;
> -
>  	int err;
>  
>  	err = pnfs_osd_xdr_decode_layout_map(&layout, &iter, xdr);
> @@ -342,14 +341,16 @@ extern int objio_alloc_lseg(struct pnfs_layout_segment **outp,
>  	if (unlikely(err))
>  		return err;
>  
> -	objio_seg = kzalloc(sizeof(*objio_seg) +
> +	objio_seg = kzalloc(sizeof(*objio_seg) + 
> +			    sizeof(objio_seg->ods[0]) * layout.olo_num_comps +
>  			    sizeof(*objio_seg->comps) * layout.olo_num_comps +
>  			    sizeof(struct caps_buffers) * layout.olo_num_comps,
>  			    GFP_KERNEL);

This hunk doesn't apply cleanly, as in the latest version
we pass gfp_flags, not GFP_KERNEL.

>  	if (!objio_seg)
>  		return -ENOMEM;
>  
> -	cur_comp = objio_seg->comps = (void *)(objio_seg + 1);
> +	objio_seg->comps = (void *)(objio_seg->ods + layout.olo_num_comps);
> +	cur_comp = objio_seg->comps;
>  	caps_p = (void *)(cur_comp + layout.olo_num_comps);
>  	while (pnfs_osd_xdr_decode_layout_comp(&src_comp, &iter, xdr, &err)) {
>  		copy_single_comp(cur_comp++, &src_comp, caps_p++);
> @@ -606,6 +607,9 @@ static int _add_stripe_unit(struct objio_state *ios,  unsigned *cur_pg,
>  		unsigned bio_size = (ios->ol_state.nr_pages + pages_in_stripe) /
>  				    stripes;
>  
> +		if (BIO_MAX_PAGES_KMALLOC < bio_size)
> +			bio_size = BIO_MAX_PAGES_KMALLOC;
> +
>  		per_dev->bio = bio_kmalloc(GFP_KERNEL, bio_size);

ditto

I'll fix that in my tree...

Benny

>  		if (unlikely(!per_dev->bio)) {
>  			dprintk("Faild to allocate BIO size=%u\n", bio_size);

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Boaz Harrosh May 24, 2011, 2:37 p.m. UTC | #2
On 05/24/2011 04:10 PM, Benny Halevy wrote:
> 
> This hunk doesn't apply cleanly, as in the latest version
> we pass gfp_flags, not GFP_KERNEL.
> 
>>  	if (!objio_seg)
>>  		return -ENOMEM;
>>  

Please don't do anything. I'm just now sending a clean
SQUASHME set

Please talk to me

Boaz]
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Benny Halevy May 24, 2011, 3:57 p.m. UTC | #3
On 2011-05-24 17:37, Boaz Harrosh wrote:
> On 05/24/2011 04:10 PM, Benny Halevy wrote:
>>
>> This hunk doesn't apply cleanly, as in the latest version
>> we pass gfp_flags, not GFP_KERNEL.
>>
>>>  	if (!objio_seg)
>>>  		return -ENOMEM;
>>>  
> 
> Please don't do anything. I'm just now sending a clean
> SQUASHME set
> 
> Please talk to me
> 
> Boaz]

OK. I'm waiting for a plumber to arrive in a few minutes
so I'll call you later today...

Benny

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Boaz Harrosh May 24, 2011, 4:04 p.m. UTC | #4
On 05/24/2011 06:57 PM, Benny Halevy wrote:
> On 2011-05-24 17:37, Boaz Harrosh wrote:
>> On 05/24/2011 04:10 PM, Benny Halevy wrote:
>>>
>>> This hunk doesn't apply cleanly, as in the latest version
>>> we pass gfp_flags, not GFP_KERNEL.
>>>
>>>>  	if (!objio_seg)
>>>>  		return -ENOMEM;
>>>>  
>>
>> Please don't do anything. I'm just now sending a clean
>> SQUASHME set
>>
>> Please talk to me
>>
>> Boaz]
> 
> OK. I'm waiting for a plumber to arrive in a few minutes
> so I'll call you later today...
> 
> Benny
> 

Thanks Benny.

I've now re-sent all the fixes in the right order and properly
separated, to be able to cleanly squash on the V6 patchset from you.
Please see my mail:
   [PATCHES 00/12] Mostly a Resend of ALL Bug fixes and SQUASHMEs - pnfs-submit 2.6.40 V7
and the thread that follows, also the proposed patch reorder.

Tell me if you also need the cleaned squashed set. It is no problem.

Boaz
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c
index 9bb5830..b6ec124 100644
--- a/fs/nfs/objlayout/objio_osd.c
+++ b/fs/nfs/objlayout/objio_osd.c
@@ -147,7 +147,7 @@  struct objio_segment {
 	unsigned comps_index;
 	unsigned num_comps;
 	/* variable length */
-	struct osd_dev	*ods[1];
+	struct osd_dev	*ods[];
 };
 
 static inline struct objio_segment *
@@ -331,7 +331,6 @@  extern int objio_alloc_lseg(struct pnfs_layout_segment **outp,
 	struct pnfs_osd_layout layout;
 	struct pnfs_osd_object_cred *cur_comp, src_comp;
 	struct caps_buffers *caps_p;
-
 	int err;
 
 	err = pnfs_osd_xdr_decode_layout_map(&layout, &iter, xdr);
@@ -342,14 +341,16 @@  extern int objio_alloc_lseg(struct pnfs_layout_segment **outp,
 	if (unlikely(err))
 		return err;
 
-	objio_seg = kzalloc(sizeof(*objio_seg) +
+	objio_seg = kzalloc(sizeof(*objio_seg) + 
+			    sizeof(objio_seg->ods[0]) * layout.olo_num_comps +
 			    sizeof(*objio_seg->comps) * layout.olo_num_comps +
 			    sizeof(struct caps_buffers) * layout.olo_num_comps,
 			    GFP_KERNEL);
 	if (!objio_seg)
 		return -ENOMEM;
 
-	cur_comp = objio_seg->comps = (void *)(objio_seg + 1);
+	objio_seg->comps = (void *)(objio_seg->ods + layout.olo_num_comps);
+	cur_comp = objio_seg->comps;
 	caps_p = (void *)(cur_comp + layout.olo_num_comps);
 	while (pnfs_osd_xdr_decode_layout_comp(&src_comp, &iter, xdr, &err)) {
 		copy_single_comp(cur_comp++, &src_comp, caps_p++);
@@ -606,6 +607,9 @@  static int _add_stripe_unit(struct objio_state *ios,  unsigned *cur_pg,
 		unsigned bio_size = (ios->ol_state.nr_pages + pages_in_stripe) /
 				    stripes;
 
+		if (BIO_MAX_PAGES_KMALLOC < bio_size)
+			bio_size = BIO_MAX_PAGES_KMALLOC;
+
 		per_dev->bio = bio_kmalloc(GFP_KERNEL, bio_size);
 		if (unlikely(!per_dev->bio)) {
 			dprintk("Faild to allocate BIO size=%u\n", bio_size);