History

iversion: add a routine to update a raw value with a larger one

Under ceph, clients can be independently updating iversion themselves, while working under comprehensive sets of caps on an inode. In that situation we always want to prefer the largest value of a change attribute. Add a new function that will update a raw value with a larger one, but otherwise leave it alone.

Jeff Layton committed 7 years ago

Commit 441d3671 parent 58981781 file · +24 −0Browse files

Showing the changes to include/linux (1 of 1 file). Show all

Unified · Split

include/linux/iversion.h+24−0
@@ -112,6 +112,30 @@ inode_peek_iversion_raw(const struct inode *inode) · 111 unmodified lines
112112 return atomic64_read(&inode->i_version);
113113 }
114114
115+/**
116+ * inode_set_max_iversion_raw - update i_version new value is larger
117+ * @inode: inode to set
118+ * @val: new i_version to set
119+ *
120+ * Some self-managed filesystems (e.g Ceph) will only update the i_version
121+ * value if the new value is larger than the one we already have.
122+ */
123+static inline void
124+inode_set_max_iversion_raw(struct inode *inode, u64 val)
125+{
126+ u64 cur, old;
127+
128+ cur = inode_peek_iversion_raw(inode);
129+ for (;;) {
130+ if (cur > val)
131+ break;
132+ old = atomic64_cmpxchg(&inode->i_version, cur, val);
133+ if (likely(old == cur))
134+ break;
135+ cur = old;
136+ }
137+}
138+
115139 /**
116140 * inode_set_iversion - set i_version to a particular value
117141 * @inode: inode to set

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t