[LU-12586] truncate to start of uninstantiated PFL component silently fails Created: 24/Jul/19  Updated: 19/Dec/20  Resolved: 01/Aug/20

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.13.0, Lustre 2.12.2, Lustre 2.10.8
Fix Version/s: Lustre 2.14.0

Type: Bug Priority: Critical
Reporter: Patrick Farrell (Inactive) Assignee: Zhenyu Xu
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
Related
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

Truncate to exactly the first byte of an uninstantiated PFL component doesn't work - It has no effect.

Example:

[root@cent7c02 lustre]# mkdir testdir; lfs setstripe -E 4M --stripe-count=1 -E -1 testdir
[root@cent7c02 lustre]# touch testdir/testfile; lfs getstripe testdir/testfile
testdir/testfile
  lcm_layout_gen:    2
  lcm_mirror_count:  1
  lcm_entry_count:   2
    lcme_id:             1
    lcme_mirror_id:      0
    lcme_flags:          init
    lcme_extent.e_start: 0
    lcme_extent.e_end:   4194304
      lmm_stripe_count:  1
      lmm_stripe_size:   1048576
      lmm_pattern:       raid0
      lmm_layout_gen:    0
      lmm_stripe_offset: 0
      lmm_objects:
      - 0: { l_ost_idx: 0, l_fid: [0x100000000:0x24b:0x0] }    lcme_id:             2
    lcme_mirror_id:      0
    lcme_flags:          0
    lcme_extent.e_start: 4194304
    lcme_extent.e_end:   EOF
      lmm_stripe_count:  1
      lmm_stripe_size:   1048576
      lmm_pattern:       raid0
      lmm_layout_gen:    0
      lmm_stripe_offset: -1[root@cent7c02 lustre]# truncate --size 4194304 testdir/testfile; ls -la testdir/testfile
-rw-r--r-- 1 root root 0 Jul 24 15:11 testdir/testfile
[root@cent7c02 lustre]# truncate --size 4194303 testdir/testfile; ls -la testdir/testfile
-rw-r--r-- 1 root root 4194303 Jul 24 15:11 testdir/testfile
[root@cent7c02 lustre]# truncate --size 4194305 testdir/testfile; ls -la testdir/testfile
-rw-r--r-- 1 root root 4194305 Jul 24 15:11 testdir/testfile 

Notice that the truncate to 4 MiB (4194304) leaves the size at 0, but truncate to 4194303 or 4194305 works fine.

Once the component is instantiated, this works fine:

[root@cent7c02 lustre]# truncate --size 4194305 testdir/testfile; ls -la testdir/testfile
-rw-r--r-- 1 root root 4194305 Jul 24 15:14 testdir/testfile
[root@cent7c02 lustre]# lfs getstripe testdir/testfile
testdir/testfile
  lcm_layout_gen:    3
  lcm_mirror_count:  1
  lcm_entry_count:   2
    lcme_id:             1
    lcme_mirror_id:      0
    lcme_flags:          init
    lcme_extent.e_start: 0
    lcme_extent.e_end:   4194304
      lmm_stripe_count:  1
      lmm_stripe_size:   1048576
      lmm_pattern:       raid0
      lmm_layout_gen:    0
      lmm_stripe_offset: 1
      lmm_objects:
      - 0: { l_ost_idx: 1, l_fid: [0x100010000:0x24d:0x0] }    lcme_id:             2
    lcme_mirror_id:      0
    lcme_flags:          init
    lcme_extent.e_start: 4194304
    lcme_extent.e_end:   EOF
      lmm_stripe_count:  1
      lmm_stripe_size:   1048576
      lmm_pattern:       raid0
      lmm_layout_gen:    0
      lmm_stripe_offset: 0
      lmm_objects:
      - 0: { l_ost_idx: 0, l_fid: [0x100000000:0x24e:0x0] }
[root@cent7c02 lustre]# truncate --size 4194304 testdir/testfile; ls -la testdir/testfile
-rw-r--r-- 1 root root 4194304 Jul 24 15:14 testdir/testfile 

This is due to a slightly mixup in the write intent code between "end" for truncate, which is a size, and "end" for a normal write, which is actually "endpos", ie, the position of the write cursor after a write, which is not actually accessed and so does not need to be instantiated.  But "end" for truncate is not endpos, it's end, ie, it's included.

Fix coming momentarily.



 Comments   
Comment by Gerrit Updater [ 24/Jul/19 ]

Patrick Farrell (pfarrell@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/35607
Subject: LU-12586 lov: Correct write_intent end for trunc
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 38aa7eb4578a204658eafc923da2aba1e7bbac36

Comment by Gerrit Updater [ 15/Aug/19 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/35607/
Subject: LU-12586 lov: Correct write_intent end for trunc
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: c32c7401426d46b371fa993bba17265443fefa1b

Comment by Peter Jones [ 15/Aug/19 ]

Landed for 2.13

Comment by Gerrit Updater [ 19/Aug/19 ]

Minh Diep (mdiep@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/35836
Subject: LU-12586 lov: Correct write_intent end for trunc
Project: fs/lustre-release
Branch: b2_12
Current Patch Set: 1
Commit: 289d1e93d4cbf7be9757475dd0d222835e11d967

Comment by Gerrit Updater [ 04/Sep/19 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/35836/
Subject: LU-12586 lov: Correct write_intent end for trunc
Project: fs/lustre-release
Branch: b2_12
Current Patch Set:
Commit: ad52ac24a1d7969bfa007def9992110cf4c0888a

Comment by Gerrit Updater [ 29/Apr/20 ]

Bobi Jam (bobijam@hotmail.com) uploaded a new patch: https://review.whamcloud.com/38412
Subject: LU-12586 lov: Correct write_intent end for trunc
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 9276069349fbb7f4d81d26873e24cab52e128912

Comment by Zhenyu Xu [ 29/Apr/20 ]

An omission of the patch setting truncate write intent extent is pushed at https://review.whamcloud.com/#/c/38412/

Comment by Gerrit Updater [ 17/Jul/20 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/38412/
Subject: LU-12586 lov: one more fix to write_intent end for trunc
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 8ecf9e229cf59def03bb9368ec88228ff6e943f0

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