aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/misc.h
diff options
context:
space:
mode:
authorAdrian Hunter <ext-adrian.hunter@nokia.com>2008-08-22 07:23:35 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-08-25 07:34:02 -0400
commit601c0bc46753007be011b513ba4fc50ed8e30aef (patch)
tree39017065a8418b60362686a7771afe138e100c08 /fs/ubifs/misc.h
parent761e29f3bb19b05bea55285dfdf2d28e001a63b8 (diff)
UBIFS: allow for racing between GC and TNC
The TNC mutex is unlocked prematurely when reading leaf nodes with non-hashed keys. This is unsafe because the node may be moved by garbage collection and the eraseblock unmapped, although that has never actually happened during stress testing. This patch fixes the flaw by detecting the race and retrying with the TNC mutex locked. Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Diffstat (limited to 'fs/ubifs/misc.h')
-rw-r--r--fs/ubifs/misc.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h
index 87dabf9fe742..87ced4c74a61 100644
--- a/fs/ubifs/misc.h
+++ b/fs/ubifs/misc.h
@@ -325,4 +325,21 @@ static inline struct timespec ubifs_current_time(struct inode *inode)
325 current_fs_time(inode->i_sb) : CURRENT_TIME_SEC; 325 current_fs_time(inode->i_sb) : CURRENT_TIME_SEC;
326} 326}
327 327
328/**
329 * ubifs_tnc_lookup - look up a file-system node.
330 * @c: UBIFS file-system description object
331 * @key: node key to lookup
332 * @node: the node is returned here
333 *
334 * This function look up and reads node with key @key. The caller has to make
335 * sure the @node buffer is large enough to fit the node. Returns zero in case
336 * of success, %-ENOENT if the node was not found, and a negative error code in
337 * case of failure.
338 */
339static inline int ubifs_tnc_lookup(struct ubifs_info *c,
340 const union ubifs_key *key, void *node)
341{
342 return ubifs_tnc_locate(c, key, node, NULL, NULL);
343}
344
328#endif /* __UBIFS_MISC_H__ */ 345#endif /* __UBIFS_MISC_H__ */