Linus Torvalds writes: (Summary)
Now you can write the xattr:
Now you can write the xattr:
- get exclusive inode lock (for xattr)
- get generation count lock
- if the appraisal generation does not match, do NOT write the appraisal you just calculated, since it's pointless: it's already stale.
- otherwise write the appraisal and generation count to the xattr - drop generation count lock
- release exclusive inode lock
- release exclusive inode lock
and then for anything that does setxattr or chmod or whatever, just use that generation count lock to invalidate the appraisal.
Now you can write the xattr:
- get exclusive inode lock (for xattr)
- get generation count lock
- if the appraisal generation does not match, do NOT write the appraisal you just calculated, since it's pointless: it's already stale.
- otherwise write the appraisal and generation count to the xattr - drop generation count lock
- release exclusive inode lock
- release exclusive inode lock
and then for anything that does setxattr or chmod or whatever, just use that generation count lock to invalidate the appraisal.