From patchwork Mon May 23 19:45:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boaz Harrosh X-Patchwork-Id: 809942 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4NJjexM015781 for ; Mon, 23 May 2011 19:45:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932597Ab1EWTpi (ORCPT ); Mon, 23 May 2011 15:45:38 -0400 Received: from daytona.panasas.com ([67.152.220.89]:17542 "EHLO daytona.panasas.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932594Ab1EWTph (ORCPT ); Mon, 23 May 2011 15:45:37 -0400 Received: from fs2.bhalevy.com ([172.17.33.65]) by daytona.panasas.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 23 May 2011 15:45:36 -0400 Message-ID: <4DDAB94C.6070407@panasas.com> Date: Mon, 23 May 2011 22:45:16 +0300 From: Boaz Harrosh User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110430 Remi/fc12 Thunderbird/3.1.10 MIME-Version: 1.0 To: Benny Halevy CC: Trond Myklebust , linux-nfs@vger.kernel.org Subject: [PATCH] SQUASHME: objio read/write patch: Bugs fixes References: <4DDA8C3D.5080706@panasas.com> <1306168626-11463-1-git-send-email-bhalevy@panasas.com> In-Reply-To: <1306168626-11463-1-git-send-email-bhalevy@panasas.com> X-OriginalArrivalTime: 23 May 2011 19:45:37.0183 (UTC) FILETIME=[FCEDF2F0:01CC1981] Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 23 May 2011 19:45:40 +0000 (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 --- 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); 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);