[LU-3209] layout swap with stripeless files allows layout gen collisions Created: 23/Apr/13  Updated: 11/Mar/22  Resolved: 11/Mar/22

Status: Closed
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.4.0
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: John Hammond Assignee: John Hammond
Resolution: Won't Fix Votes: 0
Labels: hsm, mdd

Severity: 3
Rank (Obsolete): 7841

 Description   

When swapping layouts between two files f0 and f1, if f1 has no striping then the layout gen of f0 is not incremented. This can be used to create layout gen collisions and cache inconsistencies:

# cd ~/lustre-release
# git describe
2.3.64-30-g5b91c09
# MOUNT_2=y llmount.sh
...
# cd /mnt/lustre
# touch f0
# multiop f1 m
# lfs swap_layouts /mnt/lustre2/f0 /mnt/lustre2/f1
# echo HI > /mnt/lustre2/f0
# cat f0
# cat /mnt/lustre2/f0
HI
# MOUNT_2=y llmount.sh
...
# cd /mnt/lustre
# echo OLD > f0
# echo NEW > f1
# multiop f2 m ## mknod
# lfs getstripe f0
f0
lmm_stripe_count:   1
lmm_stripe_size:    1048576
lmm_layout_gen:     0
lmm_stripe_offset:  1
	obdidx		 objid		 objid		 group
	     1	             2	          0x2	             0

# lfs swap_layouts /mnt/lustre2/f0 /mnt/lustre2/f2
# lfs swap_layouts /mnt/lustre2/f0 /mnt/lustre2/f1
# lfs getstripe f0
f0
lmm_stripe_count:   1
lmm_stripe_size:    1048576
lmm_layout_gen:     0
lmm_stripe_offset:  0
	obdidx		 objid		 objid		 group
	     0	             2	          0x2	             0

# cat f0
OLD
# cat /mnt/lustre2/f0
NEW
# cat f0
OLD
# cat /mnt/lustre2/f0
NEW
# MOUNT_2=y llmount.sh
...
# cd /mnt/lustre
# touch f0
# multiop f1 m
# lfs swap_layouts /mnt/lustre2/f0 /mnt/lustre2/f1
# echo > /mnt/lustre2/f0
#
# stat f0
  File: `f0'
  Size: 0               Blocks: 0          IO Block: 4194304 regular empty file
Device: 2c54f966h/743766374d    Inode: 144115205255725134  Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-04-23 12:04:26.000000000 -0500
Modify: 2013-04-23 12:04:26.000000000 -0500
Change: 2013-04-23 12:04:26.000000000 -0500
# stat f1
stat: cannot stat `f1': Input/output error


 Comments   
Comment by Jinshan Xiong (Inactive) [ 23/Apr/13 ]

The problem is there is nowhere to store generation for an empty layout file. The only thing we can do is to hope customers won't run this test cases

Comment by jacques-charles lafoucriere [ 24/Apr/13 ]

We can forbid swap or transform the empty file into a released file before swaping

Comment by Andreas Dilger [ 24/Apr/13 ]

Hmm, doesn't layout swap preserve the layout version on each file? I thought that was part of the original patch. That would make sense since the layout version only makes sense for the file that was being modified.

Comment by jacques-charles lafoucriere [ 24/Apr/13 ]

layout swap increases each generation number, the issue with stripeless file is that we have no place to store it, or we have to transform it to a released layout

Comment by Andreas Dilger [ 24/Apr/13 ]

For HSM, the layout would be LOV_PATTERN_RELEASED, so it will have a place to store the layout generation. For stripeless files, I'm not sure whether there is a real-world issue or not, since I don't see any valid case of swapping the an empty layout and then keeping the empty file.

Comment by Jinshan Xiong (Inactive) [ 25/Apr/13 ]

"For HSM, the layout would be LOV_PATTERN_RELEASED, so it will have a place to store the layout generation. For stripeless files, I'm not sure whether there is a real-world issue or not, since I don't see any valid case of swapping the an empty layout and then keeping the empty file."

This sounds reasonable. There should be no this kind of issue in real world.

Comment by jacques-charles lafoucriere [ 25/Apr/13 ]

If we do not see any use case, the best is to forbid it so no risk of side effects

Comment by Jinshan Xiong (Inactive) [ 25/Apr/13 ]

In that case, let me work out a patch.

Generated at Sat Feb 10 01:31:54 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.