[LU-14423] osd_is_mapped() does not recognize holes Created: 11/Feb/21  Updated: 07/Nov/22  Resolved: 26/Feb/21

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.15.0

Type: Bug Priority: Minor
Reporter: Alex Zhuravlev Assignee: Alex Zhuravlev
Resolution: Fixed Votes: 0
Labels: None

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

 Description   

ldiskfs_fiemap() can return a hole in form

{0,0,0}

and then the following construction recognizes this as an allocated space:

        if (start > block) {
                cached_extent->start = block;
                cached_extent->end = start;
                cached_extent->mapped = 0;
        } else {
                cached_extent->start = start;
                cached_extent->end = (fe.fe_logical + fe.fe_length) >>
                                      inode->i_blkbits;
                cached_extent->mapped = 1;
        }


 Comments   
Comment by Gerrit Updater [ 11/Feb/21 ]

Alex Zhuravlev (bzzz@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/41481
Subject: LU-14423 osd: recognize holes in osd_is_mapped()
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 1ce62777a493b7496005c668677bddaae5a12cf8

Comment by Andreas Dilger [ 11/Feb/21 ]

Alex, AFAIK FIEMAP should not be returning 0,0,0 as a hole. That is just an uninitialized buffer and should be outside the number of returned extents? Holes in the file should just be skipped in the returned extents.

Comment by Alex Zhuravlev [ 11/Feb/21 ]

hmm, this is what I exactly got using linux-3.10.0-957.12.2.el7 - ldiskfs_fiemap() returned 0 and

{.fe_logical=0, fe_length=0}

for non-allocated block.
the file's size was set using truncate.

Comment by Andreas Dilger [ 11/Feb/21 ]

What did it return for the extent count? This may be a bug in ldiskfs.

Comment by Alex Zhuravlev [ 11/Feb/21 ]

What did it return for the extent count? This may be a bug in ldiskfs

fei.fi_extents_mapped was not touched in this case. i.e. it would be 0 for the first call to ldiskfs_fiemap() and 1 if the previous call found an extemt.
fe.fe_* were reset to 0 though.

Comment by Alex Zhuravlev [ 11/Feb/21 ]

AFAICS, fiemap can't return an extent covering a hole to EOF? thus we'd have to lookup each block separately?

Comment by Andreas Dilger [ 11/Feb/21 ]

Correct - FIEMAP does not return anything for a hole. If there are no blocks allocated to a file at all, then it should return no extent in that case. I guess you could use the 0,0 return to detect that, though it is a bit non-standard.

Comment by Gerrit Updater [ 26/Feb/21 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/41481/
Subject: LU-14423 osd: recognize holes in osd_is_mapped()
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 2eaa49ef0f16798d564883b16cea9e96fad52495

Comment by Peter Jones [ 26/Feb/21 ]

Landed for 2.15

Comment by Gerrit Updater [ 09/Nov/21 ]

"Andreas Dilger <adilger@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/45504
Subject: LU-14423 osd: recognize holes in osd_is_mapped()
Project: fs/lustre-release
Branch: b2_14
Current Patch Set: 1
Commit: 543fc7629b06a3cffb8d5ee1830c09a86f91e317

Comment by Gerrit Updater [ 14/Nov/21 ]

"Andreas Dilger <adilger@whamcloud.com>" merged in patch https://review.whamcloud.com/45504/
Subject: LU-14423 osd: recognize holes in osd_is_mapped()
Project: fs/lustre-release
Branch: b2_14
Current Patch Set:
Commit: b5f71a7e7528831a0a2c7d02b5bd98d68fcb1855

Generated at Sat Feb 10 03:09:36 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.