Thread (3 messages) 3 messages, 3 authors, 2005-09-21

Re: [PATCH 1/4] hugetlbfs: move free_inodes accounting

From: Andrew Morton <hidden>
Date: 2005-09-21 19:14:38
Also in: linux-fsdevel

Christoph Hellwig [off-list ref] wrote:
+static inline int hugetlbfs_inc_free_inodes(struct hugetlbfs_sb_info *sbinfo)
 +{
 +	if (sbinfo->free_inodes >= 0) {
 +		spin_lock(&sbinfo->stat_lock);
 +		if (unlikely(!sbinfo->free_inodes)) {
 +			spin_unlock(&sbinfo->stat_lock);
 +			return 0;
 +		}
 +		sbinfo->free_inodes--;
 +		spin_unlock(&sbinfo->stat_lock);
 +	}
 +
 +	return 1;
 +}
 +
 +static void hugetlbfs_dec_free_inodes(struct hugetlbfs_sb_info *sbinfo)
 +{
 +	if (sbinfo->free_inodes >= 0) {
 +		spin_lock(&sbinfo->stat_lock);
 +		sbinfo->free_inodes++;
 +		spin_unlock(&sbinfo->stat_lock);
 +	}
 +}
 +

These functions seem to be called from the right places, but the naming is
most confusing.

The test for the current value of sbinfo->free_inodes in
hugetlbfs_dec_free_inodes() looks racy and the logic simply escapes me. 
Does anyone remember why we have special-case handling in there for
(sbinfo->free_inodes < 0)?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help