Skip to content

Commit 660d1eb

Browse files
author
Trond Myklebust
committed
pNFS/flexfile: Don't merge layout segments if the mirrors don't match
Check that the number of mirrors, and the mirror information matches before deciding to merge layout segments in pNFS/flexfiles. Signed-off-by: Trond Myklebust <[email protected]>
1 parent e18c18e commit 660d1eb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

fs/nfs/flexfilelayout/flexfilelayout.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,23 @@ static void _ff_layout_free_lseg(struct nfs4_ff_layout_segment *fls)
283283
}
284284
}
285285

286+
static bool
287+
ff_lseg_match_mirrors(struct pnfs_layout_segment *l1,
288+
struct pnfs_layout_segment *l2)
289+
{
290+
const struct nfs4_ff_layout_segment *fl1 = FF_LAYOUT_LSEG(l1);
291+
const struct nfs4_ff_layout_segment *fl2 = FF_LAYOUT_LSEG(l1);
292+
u32 i;
293+
294+
if (fl1->mirror_array_cnt != fl2->mirror_array_cnt)
295+
return false;
296+
for (i = 0; i < fl1->mirror_array_cnt; i++) {
297+
if (fl1->mirror_array[i] != fl2->mirror_array[i])
298+
return false;
299+
}
300+
return true;
301+
}
302+
286303
static bool
287304
ff_lseg_range_is_after(const struct pnfs_layout_range *l1,
288305
const struct pnfs_layout_range *l2)
@@ -318,6 +335,8 @@ ff_lseg_merge(struct pnfs_layout_segment *new,
318335
new->pls_range.length);
319336
if (new_end < old->pls_range.offset)
320337
return false;
338+
if (!ff_lseg_match_mirrors(new, old))
339+
return false;
321340

322341
/* Mergeable: copy info from 'old' to 'new' */
323342
if (new_end < old_end)

0 commit comments

Comments
 (0)