Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 294559
b: refs/heads/master
c: 5318a29
h: refs/heads/master
i:
  294557: 033a1d7
  294555: aca7418
  294551: f5cc9e2
  294543: e9aabb5
  294527: b468bf9
v: v3
  • Loading branch information
Boaz Harrosh authored and Trond Myklebust committed Mar 14, 2012
1 parent d81003a commit 09679a2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e138ead73f872559778bb0c326e795206f96d3ce
refs/heads/master: 5318a29c1943e9719e71495db6efb6fc084a45a9
39 changes: 25 additions & 14 deletions trunk/fs/nfs/objlayout/objio_osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,25 +205,36 @@ static void copy_single_comp(struct ore_components *oc, unsigned c,
int __alloc_objio_seg(unsigned numdevs, gfp_t gfp_flags,
struct objio_segment **pseg)
{
struct __alloc_objio_segment {
struct objio_segment olseg;
struct ore_dev *ods[numdevs];
struct ore_comp comps[numdevs];
} *aolseg;

aolseg = kzalloc(sizeof(*aolseg), gfp_flags);
if (unlikely(!aolseg)) {
/* This is the in memory structure of the objio_segment
*
* struct __alloc_objio_segment {
* struct objio_segment olseg;
* struct ore_dev *ods[numdevs];
* struct ore_comp comps[numdevs];
* } *aolseg;
* NOTE: The code as above compiles and runs perfectly. It is elegant,
* type safe and compact. At some Past time Linus has decided he does not
* like variable length arrays, For the sake of this principal we uglify
* the code as below.
*/
struct objio_segment *lseg;
size_t lseg_size = sizeof(*lseg) +
numdevs * sizeof(lseg->oc.ods[0]) +
numdevs * sizeof(*lseg->oc.comps);

lseg = kzalloc(lseg_size, gfp_flags);
if (unlikely(!lseg)) {
dprintk("%s: Faild allocation numdevs=%d size=%zd\n", __func__,
numdevs, sizeof(*aolseg));
numdevs, lseg_size);
return -ENOMEM;
}

aolseg->olseg.oc.numdevs = numdevs;
aolseg->olseg.oc.single_comp = EC_MULTPLE_COMPS;
aolseg->olseg.oc.comps = aolseg->comps;
aolseg->olseg.oc.ods = aolseg->ods;
lseg->oc.numdevs = numdevs;
lseg->oc.single_comp = EC_MULTPLE_COMPS;
lseg->oc.ods = (void *)(lseg + 1);
lseg->oc.comps = (void *)(lseg->oc.ods + numdevs);

*pseg = &aolseg->olseg;
*pseg = lseg;
return 0;
}

Expand Down

0 comments on commit 09679a2

Please sign in to comment.