X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=fs%2Fubifs%2Fmisc.h;h=4fa81d867e4107cc726074a78762abb5f681ca63;hb=ba60ecabf067c8ecbde47af4d99b74ee57234d8e;hp=87dabf9fe742ea05674ec8cb2bf78f5fe98f510d;hpb=40a342664078ebcb4006a89af96f7982fac36032;p=linux-2.6-omap-h63xx.git diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h index 87dabf9fe74..4fa81d867e4 100644 --- a/fs/ubifs/misc.h +++ b/fs/ubifs/misc.h @@ -284,45 +284,57 @@ static inline void *ubifs_idx_key(const struct ubifs_info *c, } /** - * ubifs_reported_space - calculate reported free space. - * @c: the UBIFS file-system description object - * @free: amount of free space - * - * This function calculates amount of free space which will be reported to - * user-space. User-space application tend to expect that if the file-system - * (e.g., via the 'statfs()' call) reports that it has N bytes available, they - * are able to write a file of size N. UBIFS attaches node headers to each data - * node and it has to write indexind nodes as well. This introduces additional - * overhead, and UBIFS it has to report sligtly less free space to meet the - * above expectetion. - * - * This function assumes free space is made up of uncompressed data nodes and - * full index nodes (one per data node, doubled because we always allow enough - * space to write the index twice). - * - * Note, the calculation is pessimistic, which means that most of the time - * UBIFS reports less space than it actually has. + * ubifs_current_time - round current time to time granularity. + * @inode: inode */ -static inline long long ubifs_reported_space(const struct ubifs_info *c, - uint64_t free) +static inline struct timespec ubifs_current_time(struct inode *inode) { - int divisor, factor; + return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ? + current_fs_time(inode->i_sb) : CURRENT_TIME_SEC; +} - divisor = UBIFS_MAX_DATA_NODE_SZ + (c->max_idx_node_sz * 3); - factor = UBIFS_MAX_DATA_NODE_SZ - UBIFS_DATA_NODE_SZ; - do_div(free, divisor); +/** + * ubifs_tnc_lookup - look up a file-system node. + * @c: UBIFS file-system description object + * @key: node key to lookup + * @node: the node is returned here + * + * This function look up and reads node with key @key. The caller has to make + * sure the @node buffer is large enough to fit the node. Returns zero in case + * of success, %-ENOENT if the node was not found, and a negative error code in + * case of failure. + */ +static inline int ubifs_tnc_lookup(struct ubifs_info *c, + const union ubifs_key *key, void *node) +{ + return ubifs_tnc_locate(c, key, node, NULL, NULL); +} - return free * factor; +/** + * ubifs_get_lprops - get reference to LEB properties. + * @c: the UBIFS file-system description object + * + * This function locks lprops. Lprops have to be unlocked by + * 'ubifs_release_lprops()'. + */ +static inline void ubifs_get_lprops(struct ubifs_info *c) +{ + mutex_lock(&c->lp_mutex); } /** - * ubifs_current_time - round current time to time granularity. - * @inode: inode + * ubifs_release_lprops - release lprops lock. + * @c: the UBIFS file-system description object + * + * This function has to be called after each 'ubifs_get_lprops()' call to + * unlock lprops. */ -static inline struct timespec ubifs_current_time(struct inode *inode) +static inline void ubifs_release_lprops(struct ubifs_info *c) { - return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ? - current_fs_time(inode->i_sb) : CURRENT_TIME_SEC; + ubifs_assert(mutex_is_locked(&c->lp_mutex)); + ubifs_assert(c->lst.empty_lebs >= 0 && + c->lst.empty_lebs <= c->main_lebs); + mutex_unlock(&c->lp_mutex); } #endif /* __UBIFS_MISC_H__ */