[LU-2532] Link counts of osd-ldiskfs directories should be initialized via do_ref_add, rather than dio_insert Created: 05/Apr/12  Updated: 16/Apr/20  Resolved: 16/Apr/20

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

Type: Improvement Priority: Minor
Reporter: Li Wei (Inactive) Assignee: Alex Zhuravlev
Resolution: Fixed Votes: 0
Labels: None

Story Points: 2
Rank (Obsolete): 2974

 Description   
One osd-ldiskfs issue not fixed in ORI-577 is that link counts of new
directories are not initialized by the reference addition and deletion
interface, but by the index insertion interface.  Callers should still
add references for "." and ".." on new directories, but must do so
_before_ inserting the "." and "..".

We could possibly implement a fix like this:

 - dio_insert and dio_delete never update link counts, not even
   for "." and "..".

   * Revise ldiskfs_add_dot_dotdot() to be able to add "." and
     ".." separately, without changing link counts.  (Maybe we
     don't need a special function here; the generic
     ldiskfs_add_entry() works for "." and ".."?)

   * Revise ldiskfs_create_inode() to initial i_fop, i_op, etc.,
     for directory inodes.  This is currently done by
     ldiskfs_add_dot_dotdot().  (We may also set i_nlink to zero
     here, as the API between LDiskFS and Lustre is being
     changed anyway.)

 - do_ref_add and do_ref_del always work as expected for
   directories.

   * A flag should be set for new directory in-memory objects,
     indicating it's not yet initialized with "." and "..".

   * do_ref_add clears the flag if it is set and the link count
     is going from one to two.

   * The DIR_NLINK stuff in do_ref_add and do_ref_del works only
     when the flag is absent.

   * This scheme assumes that the creation of a directory object
     and its initialization (i.e., link count, ".", and "..")
     happen in one transaction, which I think is quite
     reasonable.


 Comments   
Comment by Alex Zhuravlev [ 16/Apr/20 ]

fixed long ago

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