X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosd-ldiskfs%2Fosd_iam.c;h=a92df9c96c774cce8bdeff3cf98a40587d845745;hb=8ad05ae2dc7f34180353526920e80765fd7b82d4;hp=b6e16a7f3f28e92fd766712ab542e67f76a345cf;hpb=966d0a25ba7ad6f4a58cdd25748fa356d8880e9b;p=fs%2Flustre-release.git diff --git a/lustre/osd-ldiskfs/osd_iam.c b/lustre/osd-ldiskfs/osd_iam.c index b6e16a7..a92df9c 100644 --- a/lustre/osd-ldiskfs/osd_iam.c +++ b/lustre/osd-ldiskfs/osd_iam.c @@ -157,11 +157,11 @@ * * No locking. Callers synchronize. */ -static CFS_LIST_HEAD(iam_formats); +static struct list_head iam_formats = LIST_HEAD_INIT(iam_formats); void iam_format_register(struct iam_format *fmt) { - cfs_list_add(&fmt->if_linkage, &iam_formats); + list_add(&fmt->if_linkage, &iam_formats); } EXPORT_SYMBOL(iam_format_register); @@ -173,7 +173,7 @@ iam_load_idle_blocks(struct iam_container *c, iam_ptr_t blk) struct buffer_head *bh; int err; - LASSERT_SEM_LOCKED(&c->ic_idle_sem); + LASSERT(mutex_is_locked(&c->ic_idle_mutex)); if (blk == 0) return NULL; @@ -222,7 +222,7 @@ static int iam_format_guess(struct iam_container *c) } result = -ENOENT; - cfs_list_for_each_entry(fmt, &iam_formats, if_linkage) { + list_for_each_entry(fmt, &iam_formats, if_linkage) { result = fmt->if_guess(c); if (result == 0) break; @@ -237,13 +237,13 @@ static int iam_format_guess(struct iam_container *c) idle_blocks = (__u32 *)(c->ic_root_bh->b_data + c->ic_descr->id_root_gap + sizeof(struct dx_countlimit)); - down(&c->ic_idle_sem); + mutex_lock(&c->ic_idle_mutex); bh = iam_load_idle_blocks(c, le32_to_cpu(*idle_blocks)); if (bh != NULL && IS_ERR(bh)) result = PTR_ERR(bh); else c->ic_idle_bh = bh; - up(&c->ic_idle_sem); + mutex_unlock(&c->ic_idle_mutex); } return result; @@ -260,7 +260,7 @@ int iam_container_init(struct iam_container *c, c->ic_object = inode; init_rwsem(&c->ic_sem); dynlock_init(&c->ic_tree_lock); - sema_init(&c->ic_idle_sem, 1); + mutex_init(&c->ic_idle_mutex); return 0; } EXPORT_SYMBOL(iam_container_init); @@ -456,33 +456,33 @@ static int iam_path_check(struct iam_path *p) static int iam_leaf_load(struct iam_path *path) { - iam_ptr_t block; - int err; - struct iam_container *c; - struct buffer_head *bh; - struct iam_leaf *leaf; - struct iam_descr *descr; - - c = path->ip_container; - leaf = &path->ip_leaf; - descr = iam_path_descr(path); - block = path->ip_frame->leaf; - if (block == 0) { - /* XXX bug 11027 */ - printk(CFS_KERN_EMERG "wrong leaf: %lu %d [%p %p %p]\n", - (long unsigned)path->ip_frame->leaf, - dx_get_count(dx_node_get_entries(path, path->ip_frame)), - path->ip_frames[0].bh, path->ip_frames[1].bh, - path->ip_frames[2].bh); - } - err = descr->id_ops->id_node_read(c, block, NULL, &bh); - if (err == 0) { - leaf->il_bh = bh; - leaf->il_curidx = block; - err = iam_leaf_ops(leaf)->init(leaf); - assert_inv(ergo(err == 0, iam_leaf_check(leaf))); - } - return err; + iam_ptr_t block; + int err; + struct iam_container *c; + struct buffer_head *bh; + struct iam_leaf *leaf; + struct iam_descr *descr; + + c = path->ip_container; + leaf = &path->ip_leaf; + descr = iam_path_descr(path); + block = path->ip_frame->leaf; + if (block == 0) { + /* XXX bug 11027 */ + printk(KERN_EMERG "wrong leaf: %lu %d [%p %p %p]\n", + (long unsigned)path->ip_frame->leaf, + dx_get_count(dx_node_get_entries(path, path->ip_frame)), + path->ip_frames[0].bh, path->ip_frames[1].bh, + path->ip_frames[2].bh); + } + err = descr->id_ops->id_node_read(c, block, NULL, &bh); + if (err == 0) { + leaf->il_bh = bh; + leaf->il_curidx = block; + err = iam_leaf_ops(leaf)->init(leaf); + assert_inv(ergo(err == 0, iam_leaf_check(leaf))); + } + return err; } static void iam_unlock_htree(struct iam_container *ic, @@ -543,7 +543,8 @@ int iam_leaf_at_end(const struct iam_leaf *leaf) return iam_leaf_ops(leaf)->at_end(leaf); } -void iam_leaf_split(struct iam_leaf *l, struct buffer_head **bh, iam_ptr_t nr) +static void iam_leaf_split(struct iam_leaf *l, struct buffer_head **bh, + iam_ptr_t nr) { iam_leaf_ops(l)->split(l, bh, nr); } @@ -749,7 +750,7 @@ static struct dynlock_handle *iam_lock_htree(struct iam_container *ic, return dynlock_lock(&ic->ic_tree_lock, value, lt, GFP_NOFS); } -int iam_index_lock(struct iam_path *path, struct dynlock_handle **lh) +static int iam_index_lock(struct iam_path *path, struct dynlock_handle **lh) { struct iam_frame *f; @@ -809,8 +810,8 @@ int dx_index_is_compat(struct iam_path *path) * */ -struct iam_entry *iam_find_position(struct iam_path *path, - struct iam_frame *frame) +static struct iam_entry *iam_find_position(struct iam_path *path, + struct iam_frame *frame) { int count; struct iam_entry *p; @@ -1036,8 +1037,8 @@ static int iam_check_full_path(struct iam_path *path, int search) * Performs path lookup and returns with found leaf (if any) locked by htree * lock. */ -int iam_lookup_lock(struct iam_path *path, - struct dynlock_handle **dl, enum dynlock_type lt) +static int iam_lookup_lock(struct iam_path *path, + struct dynlock_handle **dl, enum dynlock_type lt) { int result; @@ -1652,7 +1653,7 @@ int iam_it_key_size(const struct iam_iterator *it) } EXPORT_SYMBOL(iam_it_key_size); -struct buffer_head * +static struct buffer_head * iam_new_node(handle_t *h, struct iam_container *c, iam_ptr_t *b, int *e) { struct inode *inode = c->ic_object; @@ -1665,9 +1666,9 @@ iam_new_node(handle_t *h, struct iam_container *c, iam_ptr_t *b, int *e) if (c->ic_idle_bh == NULL) goto newblock; - down(&c->ic_idle_sem); + mutex_lock(&c->ic_idle_mutex); if (unlikely(c->ic_idle_bh == NULL)) { - up(&c->ic_idle_sem); + mutex_unlock(&c->ic_idle_mutex); goto newblock; } @@ -1685,7 +1686,7 @@ iam_new_node(handle_t *h, struct iam_container *c, iam_ptr_t *b, int *e) if (*e != 0) goto fail; - up(&c->ic_idle_sem); + mutex_unlock(&c->ic_idle_mutex); bh = ldiskfs_bread(NULL, inode, *b, 0, e); if (bh == NULL) return NULL; @@ -1723,7 +1724,7 @@ iam_new_node(handle_t *h, struct iam_container *c, iam_ptr_t *b, int *e) } c->ic_idle_bh = idle; - up(&c->ic_idle_sem); + mutex_unlock(&c->ic_idle_mutex); got: /* get write access for the found buffer head */ @@ -1740,11 +1741,11 @@ got: return bh; newblock: - bh = ldiskfs_append(h, inode, b, e); + bh = osd_ldiskfs_append(h, inode, b, e); return bh; fail: - up(&c->ic_idle_sem); + mutex_unlock(&c->ic_idle_mutex); ldiskfs_std_error(inode->i_sb, *e); return NULL; } @@ -2382,7 +2383,7 @@ static void iam_recycle_leaf(handle_t *h, struct iam_path *p, int count; int rc; - down(&c->ic_idle_sem); + mutex_lock(&c->ic_idle_mutex); if (unlikely(c->ic_idle_failed)) { rc = -EFAULT; goto unlock; @@ -2415,7 +2416,7 @@ static void iam_recycle_leaf(handle_t *h, struct iam_path *p, rc = iam_txn_dirty(h, p, c->ic_idle_bh); unlock: - up(&c->ic_idle_sem); + mutex_unlock(&c->ic_idle_mutex); if (rc != 0) CWARN("%.16s: idle blocks failed, will lose the blk %u\n", LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, blk); @@ -2525,7 +2526,7 @@ static inline int ptr_inside(void *base, size_t size, void *ptr) return (base <= ptr) && (ptr < base + size); } -int iam_frame_invariant(struct iam_frame *f) +static int iam_frame_invariant(struct iam_frame *f) { return (f->bh != NULL && @@ -2534,7 +2535,8 @@ int iam_frame_invariant(struct iam_frame *f) ptr_inside(f->bh->b_data, f->bh->b_size, f->at) && f->entries <= f->at); } -int iam_leaf_invariant(struct iam_leaf *l) + +static int iam_leaf_invariant(struct iam_leaf *l) { return l->il_bh != NULL && @@ -2544,7 +2546,7 @@ int iam_leaf_invariant(struct iam_leaf *l) l->il_entries <= l->il_at; } -int iam_path_invariant(struct iam_path *p) +static int iam_path_invariant(struct iam_path *p) { int i;