From b3b94faa5fe5968827ba0640ee9fba4b3e7f736e Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mon, 16 Jan 2006 16:50:04 +0000 Subject: [GFS2] The core of GFS2 This patch contains all the core files for GFS2. Signed-off-by: David Teigland Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 2513 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2513 insertions(+) create mode 100644 fs/gfs2/glock.c (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c new file mode 100644 index 00000000000000..321945fde12d9d --- /dev/null +++ b/fs/gfs2/glock.c @@ -0,0 +1,2513 @@ +/* + * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. + * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gfs2.h" +#include "glock.h" +#include "glops.h" +#include "inode.h" +#include "lm.h" +#include "lops.h" +#include "meta_io.h" +#include "quota.h" +#include "super.h" + +/* Must be kept in sync with the beginning of struct gfs2_glock */ +struct glock_plug { + struct list_head gl_list; + unsigned long gl_flags; +}; + +struct greedy { + struct gfs2_holder gr_gh; + struct work_struct gr_work; +}; + +typedef void (*glock_examiner) (struct gfs2_glock * gl); + +/** + * relaxed_state_ok - is a requested lock compatible with the current lock mode? + * @actual: the current state of the lock + * @requested: the lock state that was requested by the caller + * @flags: the modifier flags passed in by the caller + * + * Returns: 1 if the locks are compatible, 0 otherwise + */ + +static inline int relaxed_state_ok(unsigned int actual, unsigned requested, + int flags) +{ + if (actual == requested) + return 1; + + if (flags & GL_EXACT) + return 0; + + if (actual == LM_ST_EXCLUSIVE && requested == LM_ST_SHARED) + return 1; + + if (actual != LM_ST_UNLOCKED && (flags & LM_FLAG_ANY)) + return 1; + + return 0; +} + +/** + * gl_hash() - Turn glock number into hash bucket number + * @lock: The glock number + * + * Returns: The number of the corresponding hash bucket + */ + +static unsigned int gl_hash(struct lm_lockname *name) +{ + unsigned int h; + + h = jhash(&name->ln_number, sizeof(uint64_t), 0); + h = jhash(&name->ln_type, sizeof(unsigned int), h); + h &= GFS2_GL_HASH_MASK; + + return h; +} + +/** + * glock_free() - Perform a few checks and then release struct gfs2_glock + * @gl: The glock to release + * + * Also calls lock module to release its internal structure for this glock. + * + */ + +static void glock_free(struct gfs2_glock *gl) +{ + struct gfs2_sbd *sdp = gl->gl_sbd; + struct inode *aspace = gl->gl_aspace; + + gfs2_lm_put_lock(sdp, gl->gl_lock); + + if (aspace) + gfs2_aspace_put(aspace); + + kmem_cache_free(gfs2_glock_cachep, gl); + + atomic_dec(&sdp->sd_glock_count); +} + +/** + * gfs2_glock_hold() - increment reference count on glock + * @gl: The glock to hold + * + */ + +void gfs2_glock_hold(struct gfs2_glock *gl) +{ + kref_get(&gl->gl_ref); +} + +/* All work is done after the return from kref_put() so we + can release the write_lock before the free. */ + +static void kill_glock(struct kref *kref) +{ + struct gfs2_glock *gl = container_of(kref, struct gfs2_glock, gl_ref); + struct gfs2_sbd *sdp = gl->gl_sbd; + + gfs2_assert(sdp, gl->gl_state == LM_ST_UNLOCKED); + gfs2_assert(sdp, list_empty(&gl->gl_reclaim)); + gfs2_assert(sdp, list_empty(&gl->gl_holders)); + gfs2_assert(sdp, list_empty(&gl->gl_waiters1)); + gfs2_assert(sdp, list_empty(&gl->gl_waiters2)); + gfs2_assert(sdp, list_empty(&gl->gl_waiters3)); +} + +/** + * gfs2_glock_put() - Decrement reference count on glock + * @gl: The glock to put + * + */ + +int gfs2_glock_put(struct gfs2_glock *gl) +{ + struct gfs2_sbd *sdp = gl->gl_sbd; + struct gfs2_gl_hash_bucket *bucket = gl->gl_bucket; + int rv = 0; + + down(&sdp->sd_invalidate_inodes_mutex); + + write_lock(&bucket->hb_lock); + if (kref_put(&gl->gl_ref, kill_glock)) { + list_del_init(&gl->gl_list); + write_unlock(&bucket->hb_lock); + glock_free(gl); + rv = 1; + goto out; + } + write_unlock(&bucket->hb_lock); + out: + up(&sdp->sd_invalidate_inodes_mutex); + return rv; +} + +/** + * queue_empty - check to see if a glock's queue is empty + * @gl: the glock + * @head: the head of the queue to check + * + * This function protects the list in the event that a process already + * has a holder on the list and is adding a second holder for itself. + * The glmutex lock is what generally prevents processes from working + * on the same glock at once, but the special case of adding a second + * holder for yourself ("recursive" locking) doesn't involve locking + * glmutex, making the spin lock necessary. + * + * Returns: 1 if the queue is empty + */ + +static inline int queue_empty(struct gfs2_glock *gl, struct list_head *head) +{ + int empty; + spin_lock(&gl->gl_spin); + empty = list_empty(head); + spin_unlock(&gl->gl_spin); + return empty; +} + +/** + * search_bucket() - Find struct gfs2_glock by lock number + * @bucket: the bucket to search + * @name: The lock name + * + * Returns: NULL, or the struct gfs2_glock with the requested number + */ + +static struct gfs2_glock *search_bucket(struct gfs2_gl_hash_bucket *bucket, + struct lm_lockname *name) +{ + struct gfs2_glock *gl; + + list_for_each_entry(gl, &bucket->hb_list, gl_list) { + if (test_bit(GLF_PLUG, &gl->gl_flags)) + continue; + if (!lm_name_equal(&gl->gl_name, name)) + continue; + + kref_get(&gl->gl_ref); + + return gl; + } + + return NULL; +} + +/** + * gfs2_glock_find() - Find glock by lock number + * @sdp: The GFS2 superblock + * @name: The lock name + * + * Returns: NULL, or the struct gfs2_glock with the requested number + */ + +struct gfs2_glock *gfs2_glock_find(struct gfs2_sbd *sdp, + struct lm_lockname *name) +{ + struct gfs2_gl_hash_bucket *bucket = &sdp->sd_gl_hash[gl_hash(name)]; + struct gfs2_glock *gl; + + read_lock(&bucket->hb_lock); + gl = search_bucket(bucket, name); + read_unlock(&bucket->hb_lock); + + return gl; +} + +/** + * gfs2_glock_get() - Get a glock, or create one if one doesn't exist + * @sdp: The GFS2 superblock + * @number: the lock number + * @glops: The glock_operations to use + * @create: If 0, don't create the glock if it doesn't exist + * @glp: the glock is returned here + * + * This does not lock a glock, just finds/creates structures for one. + * + * Returns: errno + */ + +int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, + struct gfs2_glock_operations *glops, int create, + struct gfs2_glock **glp) +{ + struct lm_lockname name; + struct gfs2_glock *gl, *tmp; + struct gfs2_gl_hash_bucket *bucket; + int error; + + name.ln_number = number; + name.ln_type = glops->go_type; + bucket = &sdp->sd_gl_hash[gl_hash(&name)]; + + read_lock(&bucket->hb_lock); + gl = search_bucket(bucket, &name); + read_unlock(&bucket->hb_lock); + + if (gl || !create) { + *glp = gl; + return 0; + } + + gl = kmem_cache_alloc(gfs2_glock_cachep, GFP_KERNEL); + if (!gl) + return -ENOMEM; + + memset(gl, 0, sizeof(struct gfs2_glock)); + + INIT_LIST_HEAD(&gl->gl_list); + gl->gl_name = name; + kref_init(&gl->gl_ref); + + spin_lock_init(&gl->gl_spin); + + gl->gl_state = LM_ST_UNLOCKED; + INIT_LIST_HEAD(&gl->gl_holders); + INIT_LIST_HEAD(&gl->gl_waiters1); + INIT_LIST_HEAD(&gl->gl_waiters2); + INIT_LIST_HEAD(&gl->gl_waiters3); + + gl->gl_ops = glops; + + gl->gl_bucket = bucket; + INIT_LIST_HEAD(&gl->gl_reclaim); + + gl->gl_sbd = sdp; + + lops_init_le(&gl->gl_le, &gfs2_glock_lops); + INIT_LIST_HEAD(&gl->gl_ail_list); + + /* If this glock protects actual on-disk data or metadata blocks, + create a VFS inode to manage the pages/buffers holding them. */ + if (glops == &gfs2_inode_glops || + glops == &gfs2_rgrp_glops || + glops == &gfs2_meta_glops) { + gl->gl_aspace = gfs2_aspace_get(sdp); + if (!gl->gl_aspace) { + error = -ENOMEM; + goto fail; + } + } + + error = gfs2_lm_get_lock(sdp, &name, &gl->gl_lock); + if (error) + goto fail_aspace; + + atomic_inc(&sdp->sd_glock_count); + + write_lock(&bucket->hb_lock); + tmp = search_bucket(bucket, &name); + if (tmp) { + write_unlock(&bucket->hb_lock); + glock_free(gl); + gl = tmp; + } else { + list_add_tail(&gl->gl_list, &bucket->hb_list); + write_unlock(&bucket->hb_lock); + } + + *glp = gl; + + return 0; + + fail_aspace: + if (gl->gl_aspace) + gfs2_aspace_put(gl->gl_aspace); + + fail: + kmem_cache_free(gfs2_glock_cachep, gl); + + return error; +} + +/** + * gfs2_holder_init - initialize a struct gfs2_holder in the default way + * @gl: the glock + * @state: the state we're requesting + * @flags: the modifier flags + * @gh: the holder structure + * + */ + +void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, int flags, + struct gfs2_holder *gh) +{ + INIT_LIST_HEAD(&gh->gh_list); + gh->gh_gl = gl; + gh->gh_owner = (flags & GL_NEVER_RECURSE) ? NULL : current; + gh->gh_state = state; + gh->gh_flags = flags; + gh->gh_error = 0; + gh->gh_iflags = 0; + init_completion(&gh->gh_wait); + + if (gh->gh_state == LM_ST_EXCLUSIVE) + gh->gh_flags |= GL_LOCAL_EXCL; + + gfs2_glock_hold(gl); +} + +/** + * gfs2_holder_reinit - reinitialize a struct gfs2_holder so we can requeue it + * @state: the state we're requesting + * @flags: the modifier flags + * @gh: the holder structure + * + * Don't mess with the glock. + * + */ + +void gfs2_holder_reinit(unsigned int state, int flags, struct gfs2_holder *gh) +{ + gh->gh_state = state; + gh->gh_flags = flags; + if (gh->gh_state == LM_ST_EXCLUSIVE) + gh->gh_flags |= GL_LOCAL_EXCL; + + gh->gh_iflags &= 1 << HIF_ALLOCED; +} + +/** + * gfs2_holder_uninit - uninitialize a holder structure (drop glock reference) + * @gh: the holder structure + * + */ + +void gfs2_holder_uninit(struct gfs2_holder *gh) +{ + gfs2_glock_put(gh->gh_gl); + gh->gh_gl = NULL; +} + +/** + * gfs2_holder_get - get a struct gfs2_holder structure + * @gl: the glock + * @state: the state we're requesting + * @flags: the modifier flags + * @gfp_flags: __GFP_NOFAIL + * + * Figure out how big an impact this function has. Either: + * 1) Replace it with a cache of structures hanging off the struct gfs2_sbd + * 2) Leave it like it is + * + * Returns: the holder structure, NULL on ENOMEM + */ + +struct gfs2_holder *gfs2_holder_get(struct gfs2_glock *gl, unsigned int state, + int flags, gfp_t gfp_flags) +{ + struct gfs2_holder *gh; + + gh = kmalloc(sizeof(struct gfs2_holder), gfp_flags); + if (!gh) + return NULL; + + gfs2_holder_init(gl, state, flags, gh); + set_bit(HIF_ALLOCED, &gh->gh_iflags); + + return gh; +} + +/** + * gfs2_holder_put - get rid of a struct gfs2_holder structure + * @gh: the holder structure + * + */ + +void gfs2_holder_put(struct gfs2_holder *gh) +{ + gfs2_holder_uninit(gh); + kfree(gh); +} + +/** + * handle_recurse - put other holder structures (marked recursive) + * into the holders list + * @gh: the holder structure + * + */ + +static void handle_recurse(struct gfs2_holder *gh) +{ + struct gfs2_glock *gl = gh->gh_gl; + struct gfs2_sbd *sdp = gl->gl_sbd; + struct gfs2_holder *tmp_gh, *safe; + int found = 0; + + if (gfs2_assert_warn(sdp, gh->gh_owner)) + return; + + list_for_each_entry_safe(tmp_gh, safe, &gl->gl_waiters3, gh_list) { + if (tmp_gh->gh_owner != gh->gh_owner) + continue; + + gfs2_assert_warn(sdp, + test_bit(HIF_RECURSE, &tmp_gh->gh_iflags)); + + list_move_tail(&tmp_gh->gh_list, &gl->gl_holders); + tmp_gh->gh_error = 0; + set_bit(HIF_HOLDER, &tmp_gh->gh_iflags); + + complete(&tmp_gh->gh_wait); + + found = 1; + } + + gfs2_assert_warn(sdp, found); +} + +/** + * do_unrecurse - a recursive holder was just dropped of the waiters3 list + * @gh: the holder + * + * If there is only one other recursive holder, clear its HIF_RECURSE bit. + * If there is more than one, leave them alone. + * + */ + +static void do_unrecurse(struct gfs2_holder *gh) +{ + struct gfs2_glock *gl = gh->gh_gl; + struct gfs2_sbd *sdp = gl->gl_sbd; + struct gfs2_holder *tmp_gh, *last_gh = NULL; + int found = 0; + + if (gfs2_assert_warn(sdp, gh->gh_owner)) + return; + + list_for_each_entry(tmp_gh, &gl->gl_waiters3, gh_list) { + if (tmp_gh->gh_owner != gh->gh_owner) + continue; + + gfs2_assert_warn(sdp, + test_bit(HIF_RECURSE, &tmp_gh->gh_iflags)); + + if (found) + return; + + found = 1; + last_gh = tmp_gh; + } + + if (!gfs2_assert_warn(sdp, found)) + clear_bit(HIF_RECURSE, &last_gh->gh_iflags); +} + +/** + * rq_mutex - process a mutex request in the queue + * @gh: the glock holder + * + * Returns: 1 if the queue is blocked + */ + +static int rq_mutex(struct gfs2_holder *gh) +{ + struct gfs2_glock *gl = gh->gh_gl; + + list_del_init(&gh->gh_list); + /* gh->gh_error never examined. */ + set_bit(GLF_LOCK, &gl->gl_flags); + complete(&gh->gh_wait); + + return 1; +} + +/** + * rq_promote - process a promote request in the queue + * @gh: the glock holder + * + * Acquire a new inter-node lock, or change a lock state to more restrictive. + * + * Returns: 1 if the queue is blocked + */ + +static int rq_promote(struct gfs2_holder *gh) +{ + struct gfs2_glock *gl = gh->gh_gl; + struct gfs2_sbd *sdp = gl->gl_sbd; + struct gfs2_glock_operations *glops = gl->gl_ops; + int recurse; + + if (!relaxed_state_ok(gl->gl_state, gh->gh_state, gh->gh_flags)) { + if (list_empty(&gl->gl_holders)) { + gl->gl_req_gh = gh; + set_bit(GLF_LOCK, &gl->gl_flags); + spin_unlock(&gl->gl_spin); + + if (atomic_read(&sdp->sd_reclaim_count) > + gfs2_tune_get(sdp, gt_reclaim_limit) && + !(gh->gh_flags & LM_FLAG_PRIORITY)) { + gfs2_reclaim_glock(sdp); + gfs2_reclaim_glock(sdp); + } + + glops->go_xmote_th(gl, gh->gh_state, + gh->gh_flags); + + spin_lock(&gl->gl_spin); + } + return 1; + } + + if (list_empty(&gl->gl_holders)) { + set_bit(HIF_FIRST, &gh->gh_iflags); + set_bit(GLF_LOCK, &gl->gl_flags); + recurse = 0; + } else { + struct gfs2_holder *next_gh; + if (gh->gh_flags & GL_LOCAL_EXCL) + return 1; + next_gh = list_entry(gl->gl_holders.next, struct gfs2_holder, + gh_list); + if (next_gh->gh_flags & GL_LOCAL_EXCL) + return 1; + recurse = test_bit(HIF_RECURSE, &gh->gh_iflags); + } + + list_move_tail(&gh->gh_list, &gl->gl_holders); + gh->gh_error = 0; + set_bit(HIF_HOLDER, &gh->gh_iflags); + + if (recurse) + handle_recurse(gh); + + complete(&gh->gh_wait); + + return 0; +} + +/** + * rq_demote - process a demote request in the queue + * @gh: the glock holder + * + * Returns: 1 if the queue is blocked + */ + +static int rq_demote(struct gfs2_holder *gh) +{ + struct gfs2_glock *gl = gh->gh_gl; + struct gfs2_glock_operations *glops = gl->gl_ops; + + if (!list_empty(&gl->gl_holders)) + return 1; + + if (gl->gl_state == gh->gh_state || gl->gl_state == LM_ST_UNLOCKED) { + list_del_init(&gh->gh_list); + gh->gh_error = 0; + spin_unlock(&gl->gl_spin); + if (test_bit(HIF_DEALLOC, &gh->gh_iflags)) + gfs2_holder_put(gh); + else + complete(&gh->gh_wait); + spin_lock(&gl->gl_spin); + } else { + gl->gl_req_gh = gh; + set_bit(GLF_LOCK, &gl->gl_flags); + spin_unlock(&gl->gl_spin); + + if (gh->gh_state == LM_ST_UNLOCKED || + gl->gl_state != LM_ST_EXCLUSIVE) + glops->go_drop_th(gl); + else + glops->go_xmote_th(gl, gh->gh_state, gh->gh_flags); + + spin_lock(&gl->gl_spin); + } + + return 0; +} + +/** + * rq_greedy - process a queued request to drop greedy status + * @gh: the glock holder + * + * Returns: 1 if the queue is blocked + */ + +static int rq_greedy(struct gfs2_holder *gh) +{ + struct gfs2_glock *gl = gh->gh_gl; + + list_del_init(&gh->gh_list); + /* gh->gh_error never examined. */ + clear_bit(GLF_GREEDY, &gl->gl_flags); + spin_unlock(&gl->gl_spin); + + gfs2_holder_uninit(gh); + kfree(container_of(gh, struct greedy, gr_gh)); + + spin_lock(&gl->gl_spin); + + return 0; +} + +/** + * run_queue - process holder structures on a glock + * @gl: the glock + * + */ + +static void run_queue(struct gfs2_glock *gl) +{ + struct gfs2_holder *gh; + int blocked = 1; + + for (;;) { + if (test_bit(GLF_LOCK, &gl->gl_flags)) + break; + + if (!list_empty(&gl->gl_waiters1)) { + gh = list_entry(gl->gl_waiters1.next, + struct gfs2_holder, gh_list); + + if (test_bit(HIF_MUTEX, &gh->gh_iflags)) + blocked = rq_mutex(gh); + else + gfs2_assert_warn(gl->gl_sbd, 0); + + } else if (!list_empty(&gl->gl_waiters2) && + !test_bit(GLF_SKIP_WAITERS2, &gl->gl_flags)) { + gh = list_entry(gl->gl_waiters2.next, + struct gfs2_holder, gh_list); + + if (test_bit(HIF_DEMOTE, &gh->gh_iflags)) + blocked = rq_demote(gh); + else if (test_bit(HIF_GREEDY, &gh->gh_iflags)) + blocked = rq_greedy(gh); + else + gfs2_assert_warn(gl->gl_sbd, 0); + + } else if (!list_empty(&gl->gl_waiters3)) { + gh = list_entry(gl->gl_waiters3.next, + struct gfs2_holder, gh_list); + + if (test_bit(HIF_PROMOTE, &gh->gh_iflags)) + blocked = rq_promote(gh); + else + gfs2_assert_warn(gl->gl_sbd, 0); + + } else + break; + + if (blocked) + break; + } +} + +/** + * gfs2_glmutex_lock - acquire a local lock on a glock + * @gl: the glock + * + * Gives caller exclusive access to manipulate a glock structure. + */ + +void gfs2_glmutex_lock(struct gfs2_glock *gl) +{ + struct gfs2_holder gh; + + gfs2_holder_init(gl, 0, 0, &gh); + set_bit(HIF_MUTEX, &gh.gh_iflags); + + spin_lock(&gl->gl_spin); + if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) + list_add_tail(&gh.gh_list, &gl->gl_waiters1); + else + complete(&gh.gh_wait); + spin_unlock(&gl->gl_spin); + + wait_for_completion(&gh.gh_wait); + gfs2_holder_uninit(&gh); +} + +/** + * gfs2_glmutex_trylock - try to acquire a local lock on a glock + * @gl: the glock + * + * Returns: 1 if the glock is acquired + */ + +int gfs2_glmutex_trylock(struct gfs2_glock *gl) +{ + int acquired = 1; + + spin_lock(&gl->gl_spin); + if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) + acquired = 0; + spin_unlock(&gl->gl_spin); + + return acquired; +} + +/** + * gfs2_glmutex_unlock - release a local lock on a glock + * @gl: the glock + * + */ + +void gfs2_glmutex_unlock(struct gfs2_glock *gl) +{ + spin_lock(&gl->gl_spin); + clear_bit(GLF_LOCK, &gl->gl_flags); + run_queue(gl); + spin_unlock(&gl->gl_spin); +} + +/** + * handle_callback - add a demote request to a lock's queue + * @gl: the glock + * @state: the state the caller wants us to change to + * + */ + +static void handle_callback(struct gfs2_glock *gl, unsigned int state) +{ + struct gfs2_holder *gh, *new_gh = NULL; + + restart: + spin_lock(&gl->gl_spin); + + list_for_each_entry(gh, &gl->gl_waiters2, gh_list) { + if (test_bit(HIF_DEMOTE, &gh->gh_iflags) && + gl->gl_req_gh != gh) { + if (gh->gh_state != state) + gh->gh_state = LM_ST_UNLOCKED; + goto out; + } + } + + if (new_gh) { + list_add_tail(&new_gh->gh_list, &gl->gl_waiters2); + new_gh = NULL; + } else { + spin_unlock(&gl->gl_spin); + + new_gh = gfs2_holder_get(gl, state, + LM_FLAG_TRY | GL_NEVER_RECURSE, + GFP_KERNEL | __GFP_NOFAIL), + set_bit(HIF_DEMOTE, &new_gh->gh_iflags); + set_bit(HIF_DEALLOC, &new_gh->gh_iflags); + + goto restart; + } + + out: + spin_unlock(&gl->gl_spin); + + if (new_gh) + gfs2_holder_put(new_gh); +} + +/** + * state_change - record that the glock is now in a different state + * @gl: the glock + * @new_state the new state + * + */ + +static void state_change(struct gfs2_glock *gl, unsigned int new_state) +{ + struct gfs2_sbd *sdp = gl->gl_sbd; + int held1, held2; + + held1 = (gl->gl_state != LM_ST_UNLOCKED); + held2 = (new_state != LM_ST_UNLOCKED); + + if (held1 != held2) { + if (held2) { + atomic_inc(&sdp->sd_glock_held_count); + gfs2_glock_hold(gl); + } else { + atomic_dec(&sdp->sd_glock_held_count); + gfs2_glock_put(gl); + } + } + + gl->gl_state = new_state; +} + +/** + * xmote_bh - Called after the lock module is done acquiring a lock + * @gl: The glock in question + * @ret: the int returned from the lock module + * + */ + +static void xmote_bh(struct gfs2_glock *gl, unsigned int ret) +{ + struct gfs2_sbd *sdp = gl->gl_sbd; + struct gfs2_glock_operations *glops = gl->gl_ops; + struct gfs2_holder *gh = gl->gl_req_gh; + int prev_state = gl->gl_state; + int op_done = 1; + + gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags)); + gfs2_assert_warn(sdp, queue_empty(gl, &gl->gl_holders)); + gfs2_assert_warn(sdp, !(ret & LM_OUT_ASYNC)); + + state_change(gl, ret & LM_OUT_ST_MASK); + + if (prev_state != LM_ST_UNLOCKED && !(ret & LM_OUT_CACHEABLE)) { + if (glops->go_inval) + glops->go_inval(gl, DIO_METADATA | DIO_DATA); + } else if (gl->gl_state == LM_ST_DEFERRED) { + /* We might not want to do this here. + Look at moving to the inode glops. */ + if (glops->go_inval) + glops->go_inval(gl, DIO_DATA); + } + + /* Deal with each possible exit condition */ + + if (!gh) + gl->gl_stamp = jiffies; + + else if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) { + spin_lock(&gl->gl_spin); + list_del_init(&gh->gh_list); + gh->gh_error = -EIO; + if (test_bit(HIF_RECURSE, &gh->gh_iflags)) + do_unrecurse(gh); + spin_unlock(&gl->gl_spin); + + } else if (test_bit(HIF_DEMOTE, &gh->gh_iflags)) { + spin_lock(&gl->gl_spin); + list_del_init(&gh->gh_list); + if (gl->gl_state == gh->gh_state || + gl->gl_state == LM_ST_UNLOCKED) + gh->gh_error = 0; + else { + if (gfs2_assert_warn(sdp, gh->gh_flags & + (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) == -1) + fs_warn(sdp, "ret = 0x%.8X\n", ret); + gh->gh_error = GLR_TRYFAILED; + } + spin_unlock(&gl->gl_spin); + + if (ret & LM_OUT_CANCELED) + handle_callback(gl, LM_ST_UNLOCKED); /* Lame */ + + } else if (ret & LM_OUT_CANCELED) { + spin_lock(&gl->gl_spin); + list_del_init(&gh->gh_list); + gh->gh_error = GLR_CANCELED; + if (test_bit(HIF_RECURSE, &gh->gh_iflags)) + do_unrecurse(gh); + spin_unlock(&gl->gl_spin); + + } else if (relaxed_state_ok(gl->gl_state, gh->gh_state, gh->gh_flags)) { + spin_lock(&gl->gl_spin); + list_move_tail(&gh->gh_list, &gl->gl_holders); + gh->gh_error = 0; + set_bit(HIF_HOLDER, &gh->gh_iflags); + spin_unlock(&gl->gl_spin); + + set_bit(HIF_FIRST, &gh->gh_iflags); + + op_done = 0; + + } else if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) { + spin_lock(&gl->gl_spin); + list_del_init(&gh->gh_list); + gh->gh_error = GLR_TRYFAILED; + if (test_bit(HIF_RECURSE, &gh->gh_iflags)) + do_unrecurse(gh); + spin_unlock(&gl->gl_spin); + + } else { + if (gfs2_assert_withdraw(sdp, 0) == -1) + fs_err(sdp, "ret = 0x%.8X\n", ret); + } + + if (glops->go_xmote_bh) + glops->go_xmote_bh(gl); + + if (op_done) { + spin_lock(&gl->gl_spin); + gl->gl_req_gh = NULL; + gl->gl_req_bh = NULL; + clear_bit(GLF_LOCK, &gl->gl_flags); + run_queue(gl); + spin_unlock(&gl->gl_spin); + } + + gfs2_glock_put(gl); + + if (gh) { + if (test_bit(HIF_DEALLOC, &gh->gh_iflags)) + gfs2_holder_put(gh); + else + complete(&gh->gh_wait); + } +} + +/** + * gfs2_glock_xmote_th - Call into the lock module to acquire or change a glock + * @gl: The glock in question + * @state: the requested state + * @flags: modifier flags to the lock call + * + */ + +void gfs2_glock_xmote_th(struct gfs2_glock *gl, unsigned int state, int flags) +{ + struct gfs2_sbd *sdp = gl->gl_sbd; + struct gfs2_glock_operations *glops = gl->gl_ops; + int lck_flags = flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB | + LM_FLAG_NOEXP | LM_FLAG_ANY | + LM_FLAG_PRIORITY); + unsigned int lck_ret; + + gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags)); + gfs2_assert_warn(sdp, queue_empty(gl, &gl->gl_holders)); + gfs2_assert_warn(sdp, state != LM_ST_UNLOCKED); + gfs2_assert_warn(sdp, state != gl->gl_state); + + if (gl->gl_state == LM_ST_EXCLUSIVE) { + if (glops->go_sync) + glops->go_sync(gl, + DIO_METADATA | DIO_DATA | DIO_RELEASE); + } + + gfs2_glock_hold(gl); + gl->gl_req_bh = xmote_bh; + + atomic_inc(&sdp->sd_lm_lock_calls); + + lck_ret = gfs2_lm_lock(sdp, gl->gl_lock, gl->gl_state, state, + lck_flags); + + if (gfs2_assert_withdraw(sdp, !(lck_ret & LM_OUT_ERROR))) + return; + + if (lck_ret & LM_OUT_ASYNC) + gfs2_assert_warn(sdp, lck_ret == LM_OUT_ASYNC); + else + xmote_bh(gl, lck_ret); +} + +/** + * drop_bh - Called after a lock module unlock completes + * @gl: the glock + * @ret: the return status + * + * Doesn't wake up the process waiting on the struct gfs2_holder (if any) + * Doesn't drop the reference on the glock the top half took out + * + */ + +static void drop_bh(struct gfs2_glock *gl, unsigned int ret) +{ + struct gfs2_sbd *sdp = gl->gl_sbd; + struct gfs2_glock_operations *glops = gl->gl_ops; + struct gfs2_holder *gh = gl->gl_req_gh; + + clear_bit(GLF_PREFETCH, &gl->gl_flags); + + gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags)); + gfs2_assert_warn(sdp, queue_empty(gl, &gl->gl_holders)); + gfs2_assert_warn(sdp, !ret); + + state_change(gl, LM_ST_UNLOCKED); + + if (glops->go_inval) + glops->go_inval(gl, DIO_METADATA | DIO_DATA); + + if (gh) { + spin_lock(&gl->gl_spin); + list_del_init(&gh->gh_list); + gh->gh_error = 0; + spin_unlock(&gl->gl_spin); + } + + if (glops->go_drop_bh) + glops->go_drop_bh(gl); + + spin_lock(&gl->gl_spin); + gl->gl_req_gh = NULL; + gl->gl_req_bh = NULL; + clear_bit(GLF_LOCK, &gl->gl_flags); + run_queue(gl); + spin_unlock(&gl->gl_spin); + + gfs2_glock_put(gl); + + if (gh) { + if (test_bit(HIF_DEALLOC, &gh->gh_iflags)) + gfs2_holder_put(gh); + else + complete(&gh->gh_wait); + } +} + +/** + * gfs2_glock_drop_th - call into the lock module to unlock a lock + * @gl: the glock + * + */ + +void gfs2_glock_drop_th(struct gfs2_glock *gl) +{ + struct gfs2_sbd *sdp = gl->gl_sbd; + struct gfs2_glock_operations *glops = gl->gl_ops; + unsigned int ret; + + gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags)); + gfs2_assert_warn(sdp, queue_empty(gl, &gl->gl_holders)); + gfs2_assert_warn(sdp, gl->gl_state != LM_ST_UNLOCKED); + + if (gl->gl_state == LM_ST_EXCLUSIVE) { + if (glops->go_sync) + glops->go_sync(gl, + DIO_METADATA | DIO_DATA | DIO_RELEASE); + } + + gfs2_glock_hold(gl); + gl->gl_req_bh = drop_bh; + + atomic_inc(&sdp->sd_lm_unlock_calls); + + ret = gfs2_lm_unlock(sdp, gl->gl_lock, gl->gl_state); + + if (gfs2_assert_withdraw(sdp, !(ret & LM_OUT_ERROR))) + return; + + if (!ret) + drop_bh(gl, ret); + else + gfs2_assert_warn(sdp, ret == LM_OUT_ASYNC); +} + +/** + * do_cancels - cancel requests for locks stuck waiting on an expire flag + * @gh: the LM_FLAG_PRIORITY holder waiting to acquire the lock + * + * Don't cancel GL_NOCANCEL requests. + */ + +static void do_cancels(struct gfs2_holder *gh) +{ + struct gfs2_glock *gl = gh->gh_gl; + + spin_lock(&gl->gl_spin); + + while (gl->gl_req_gh != gh && + !test_bit(HIF_HOLDER, &gh->gh_iflags) && + !list_empty(&gh->gh_list)) { + if (gl->gl_req_bh && + !(gl->gl_req_gh && + (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) { + spin_unlock(&gl->gl_spin); + gfs2_lm_cancel(gl->gl_sbd, gl->gl_lock); + msleep(100); + spin_lock(&gl->gl_spin); + } else { + spin_unlock(&gl->gl_spin); + msleep(100); + spin_lock(&gl->gl_spin); + } + } + + spin_unlock(&gl->gl_spin); +} + +/** + * glock_wait_internal - wait on a glock acquisition + * @gh: the glock holder + * + * Returns: 0 on success + */ + +static int glock_wait_internal(struct gfs2_holder *gh) +{ + struct gfs2_glock *gl = gh->gh_gl; + struct gfs2_sbd *sdp = gl->gl_sbd; + struct gfs2_glock_operations *glops = gl->gl_ops; + + if (test_bit(HIF_ABORTED, &gh->gh_iflags)) + return -EIO; + + if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) { + spin_lock(&gl->gl_spin); + if (gl->gl_req_gh != gh && + !test_bit(HIF_HOLDER, &gh->gh_iflags) && + !list_empty(&gh->gh_list)) { + list_del_init(&gh->gh_list); + gh->gh_error = GLR_TRYFAILED; + if (test_bit(HIF_RECURSE, &gh->gh_iflags)) + do_unrecurse(gh); + run_queue(gl); + spin_unlock(&gl->gl_spin); + return gh->gh_error; + } + spin_unlock(&gl->gl_spin); + } + + if (gh->gh_flags & LM_FLAG_PRIORITY) + do_cancels(gh); + + wait_for_completion(&gh->gh_wait); + + if (gh->gh_error) + return gh->gh_error; + + gfs2_assert_withdraw(sdp, test_bit(HIF_HOLDER, &gh->gh_iflags)); + gfs2_assert_withdraw(sdp, relaxed_state_ok(gl->gl_state, + gh->gh_state, + gh->gh_flags)); + + if (test_bit(HIF_FIRST, &gh->gh_iflags)) { + gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags)); + + if (glops->go_lock) { + gh->gh_error = glops->go_lock(gh); + if (gh->gh_error) { + spin_lock(&gl->gl_spin); + list_del_init(&gh->gh_list); + if (test_and_clear_bit(HIF_RECURSE, + &gh->gh_iflags)) + do_unrecurse(gh); + spin_unlock(&gl->gl_spin); + } + } + + spin_lock(&gl->gl_spin); + gl->gl_req_gh = NULL; + gl->gl_req_bh = NULL; + clear_bit(GLF_LOCK, &gl->gl_flags); + if (test_bit(HIF_RECURSE, &gh->gh_iflags)) + handle_recurse(gh); + run_queue(gl); + spin_unlock(&gl->gl_spin); + } + + return gh->gh_error; +} + +static inline struct gfs2_holder * +find_holder_by_owner(struct list_head *head, struct task_struct *owner) +{ + struct gfs2_holder *gh; + + list_for_each_entry(gh, head, gh_list) { + if (gh->gh_owner == owner) + return gh; + } + + return NULL; +} + +/** + * recurse_check - + * + * Make sure the new holder is compatible with the pre-existing one. + * + */ + +static int recurse_check(struct gfs2_holder *existing, struct gfs2_holder *new, + unsigned int state) +{ + struct gfs2_sbd *sdp = existing->gh_gl->gl_sbd; + + if (gfs2_assert_warn(sdp, (new->gh_flags & LM_FLAG_ANY) || + !(existing->gh_flags & LM_FLAG_ANY))) + goto fail; + + if (gfs2_assert_warn(sdp, (existing->gh_flags & GL_LOCAL_EXCL) || + !(new->gh_flags & GL_LOCAL_EXCL))) + goto fail; + + if (gfs2_assert_warn(sdp, relaxed_state_ok(state, new->gh_state, + new->gh_flags))) + goto fail; + + return 0; + + fail: + set_bit(HIF_ABORTED, &new->gh_iflags); + return -EINVAL; +} + +/** + * add_to_queue - Add a holder to the wait queue (but look for recursion) + * @gh: the holder structure to add + * + */ + +static void add_to_queue(struct gfs2_holder *gh) +{ + struct gfs2_glock *gl = gh->gh_gl; + struct gfs2_holder *existing; + + if (!gh->gh_owner) + goto out; + + existing = find_holder_by_owner(&gl->gl_holders, gh->gh_owner); + if (existing) { + if (recurse_check(existing, gh, gl->gl_state)) + return; + + list_add_tail(&gh->gh_list, &gl->gl_holders); + set_bit(HIF_HOLDER, &gh->gh_iflags); + + gh->gh_error = 0; + complete(&gh->gh_wait); + + return; + } + + existing = find_holder_by_owner(&gl->gl_waiters3, gh->gh_owner); + if (existing) { + if (recurse_check(existing, gh, existing->gh_state)) + return; + + set_bit(HIF_RECURSE, &gh->gh_iflags); + set_bit(HIF_RECURSE, &existing->gh_iflags); + + list_add_tail(&gh->gh_list, &gl->gl_waiters3); + + return; + } + + out: + if (gh->gh_flags & LM_FLAG_PRIORITY) + list_add(&gh->gh_list, &gl->gl_waiters3); + else + list_add_tail(&gh->gh_list, &gl->gl_waiters3); +} + +/** + * gfs2_glock_nq - enqueue a struct gfs2_holder onto a glock (acquire a glock) + * @gh: the holder structure + * + * if (gh->gh_flags & GL_ASYNC), this never returns an error + * + * Returns: 0, GLR_TRYFAILED, or errno on failure + */ + +int gfs2_glock_nq(struct gfs2_holder *gh) +{ + struct gfs2_glock *gl = gh->gh_gl; + struct gfs2_sbd *sdp = gl->gl_sbd; + int error = 0; + + atomic_inc(&sdp->sd_glock_nq_calls); + + restart: + if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) { + set_bit(HIF_ABORTED, &gh->gh_iflags); + return -EIO; + } + + set_bit(HIF_PROMOTE, &gh->gh_iflags); + + spin_lock(&gl->gl_spin); + add_to_queue(gh); + run_queue(gl); + spin_unlock(&gl->gl_spin); + + if (!(gh->gh_flags & GL_ASYNC)) { + error = glock_wait_internal(gh); + if (error == GLR_CANCELED) { + msleep(1000); + goto restart; + } + } + + clear_bit(GLF_PREFETCH, &gl->gl_flags); + + return error; +} + +/** + * gfs2_glock_poll - poll to see if an async request has been completed + * @gh: the holder + * + * Returns: 1 if the request is ready to be gfs2_glock_wait()ed on + */ + +int gfs2_glock_poll(struct gfs2_holder *gh) +{ + struct gfs2_glock *gl = gh->gh_gl; + int ready = 0; + + spin_lock(&gl->gl_spin); + + if (test_bit(HIF_HOLDER, &gh->gh_iflags)) + ready = 1; + else if (list_empty(&gh->gh_list)) { + if (gh->gh_error == GLR_CANCELED) { + spin_unlock(&gl->gl_spin); + msleep(1000); + if (gfs2_glock_nq(gh)) + return 1; + return 0; + } else + ready = 1; + } + + spin_unlock(&gl->gl_spin); + + return ready; +} + +/** + * gfs2_glock_wait - wait for a lock acquisition that ended in a GLR_ASYNC + * @gh: the holder structure + * + * Returns: 0, GLR_TRYFAILED, or errno on failure + */ + +int gfs2_glock_wait(struct gfs2_holder *gh) +{ + int error; + + error = glock_wait_internal(gh); + if (error == GLR_CANCELED) { + msleep(1000); + gh->gh_flags &= ~GL_ASYNC; + error = gfs2_glock_nq(gh); + } + + return error; +} + +/** + * gfs2_glock_dq - dequeue a struct gfs2_holder from a glock (release a glock) + * @gh: the glock holder + * + */ + +void gfs2_glock_dq(struct gfs2_holder *gh) +{ + struct gfs2_glock *gl = gh->gh_gl; + struct gfs2_sbd *sdp = gl->gl_sbd; + struct gfs2_glock_operations *glops = gl->gl_ops; + + atomic_inc(&sdp->sd_glock_dq_calls); + + if (gh->gh_flags & GL_SYNC) + set_bit(GLF_SYNC, &gl->gl_flags); + + if (gh->gh_flags & GL_NOCACHE) + handle_callback(gl, LM_ST_UNLOCKED); + + gfs2_glmutex_lock(gl); + + spin_lock(&gl->gl_spin); + list_del_init(&gh->gh_list); + + if (list_empty(&gl->gl_holders)) { + spin_unlock(&gl->gl_spin); + + if (glops->go_unlock) + glops->go_unlock(gh); + + if (test_bit(GLF_SYNC, &gl->gl_flags)) { + if (glops->go_sync) + glops->go_sync(gl, DIO_METADATA | DIO_DATA); + } + + gl->gl_stamp = jiffies; + + spin_lock(&gl->gl_spin); + } + + clear_bit(GLF_LOCK, &gl->gl_flags); + run_queue(gl); + spin_unlock(&gl->gl_spin); +} + +/** + * gfs2_glock_prefetch - Try to prefetch a glock + * @gl: the glock + * @state: the state to prefetch in + * @flags: flags passed to go_xmote_th() + * + */ + +void gfs2_glock_prefetch(struct gfs2_glock *gl, unsigned int state, int flags) +{ + struct gfs2_glock_operations *glops = gl->gl_ops; + + spin_lock(&gl->gl_spin); + + if (test_bit(GLF_LOCK, &gl->gl_flags) || + !list_empty(&gl->gl_holders) || + !list_empty(&gl->gl_waiters1) || + !list_empty(&gl->gl_waiters2) || + !list_empty(&gl->gl_waiters3) || + relaxed_state_ok(gl->gl_state, state, flags)) { + spin_unlock(&gl->gl_spin); + return; + } + + set_bit(GLF_PREFETCH, &gl->gl_flags); + set_bit(GLF_LOCK, &gl->gl_flags); + spin_unlock(&gl->gl_spin); + + glops->go_xmote_th(gl, state, flags); + + atomic_inc(&gl->gl_sbd->sd_glock_prefetch_calls); +} + +/** + * gfs2_glock_force_drop - Force a glock to be uncached + * @gl: the glock + * + */ + +void gfs2_glock_force_drop(struct gfs2_glock *gl) +{ + struct gfs2_holder gh; + + gfs2_holder_init(gl, LM_ST_UNLOCKED, GL_NEVER_RECURSE, &gh); + set_bit(HIF_DEMOTE, &gh.gh_iflags); + + spin_lock(&gl->gl_spin); + list_add_tail(&gh.gh_list, &gl->gl_waiters2); + run_queue(gl); + spin_unlock(&gl->gl_spin); + + wait_for_completion(&gh.gh_wait); + gfs2_holder_uninit(&gh); +} + +static void greedy_work(void *data) +{ + struct greedy *gr = (struct greedy *)data; + struct gfs2_holder *gh = &gr->gr_gh; + struct gfs2_glock *gl = gh->gh_gl; + struct gfs2_glock_operations *glops = gl->gl_ops; + + clear_bit(GLF_SKIP_WAITERS2, &gl->gl_flags); + + if (glops->go_greedy) + glops->go_greedy(gl); + + spin_lock(&gl->gl_spin); + + if (list_empty(&gl->gl_waiters2)) { + clear_bit(GLF_GREEDY, &gl->gl_flags); + spin_unlock(&gl->gl_spin); + gfs2_holder_uninit(gh); + kfree(gr); + } else { + gfs2_glock_hold(gl); + list_add_tail(&gh->gh_list, &gl->gl_waiters2); + run_queue(gl); + spin_unlock(&gl->gl_spin); + gfs2_glock_put(gl); + } +} + +/** + * gfs2_glock_be_greedy - + * @gl: + * @time: + * + * Returns: 0 if go_greedy will be called, 1 otherwise + */ + +int gfs2_glock_be_greedy(struct gfs2_glock *gl, unsigned int time) +{ + struct greedy *gr; + struct gfs2_holder *gh; + + if (!time || + gl->gl_sbd->sd_args.ar_localcaching || + test_and_set_bit(GLF_GREEDY, &gl->gl_flags)) + return 1; + + gr = kmalloc(sizeof(struct greedy), GFP_KERNEL); + if (!gr) { + clear_bit(GLF_GREEDY, &gl->gl_flags); + return 1; + } + gh = &gr->gr_gh; + + gfs2_holder_init(gl, 0, GL_NEVER_RECURSE, gh); + set_bit(HIF_GREEDY, &gh->gh_iflags); + INIT_WORK(&gr->gr_work, greedy_work, gr); + + set_bit(GLF_SKIP_WAITERS2, &gl->gl_flags); + schedule_delayed_work(&gr->gr_work, time); + + return 0; +} + +/** + * gfs2_glock_nq_init - intialize a holder and enqueue it on a glock + * @gl: the glock + * @state: the state we're requesting + * @flags: the modifier flags + * @gh: the holder structure + * + * Returns: 0, GLR_*, or errno + */ + +int gfs2_glock_nq_init(struct gfs2_glock *gl, unsigned int state, int flags, + struct gfs2_holder *gh) +{ + int error; + + gfs2_holder_init(gl, state, flags, gh); + + error = gfs2_glock_nq(gh); + if (error) + gfs2_holder_uninit(gh); + + return error; +} + +/** + * gfs2_glock_dq_uninit - dequeue a holder from a glock and initialize it + * @gh: the holder structure + * + */ + +void gfs2_glock_dq_uninit(struct gfs2_holder *gh) +{ + gfs2_glock_dq(gh); + gfs2_holder_uninit(gh); +} + +/** + * gfs2_glock_nq_num - acquire a glock based on lock number + * @sdp: the filesystem + * @number: the lock number + * @glops: the glock operations for the type of glock + * @state: the state to acquire the glock in + * @flags: modifier flags for the aquisition + * @gh: the struct gfs2_holder + * + * Returns: errno + */ + +int gfs2_glock_nq_num(struct gfs2_sbd *sdp, uint64_t number, + struct gfs2_glock_operations *glops, unsigned int state, + int flags, struct gfs2_holder *gh) +{ + struct gfs2_glock *gl; + int error; + + error = gfs2_glock_get(sdp, number, glops, CREATE, &gl); + if (!error) { + error = gfs2_glock_nq_init(gl, state, flags, gh); + gfs2_glock_put(gl); + } + + return error; +} + +/** + * glock_compare - Compare two struct gfs2_glock structures for sorting + * @arg_a: the first structure + * @arg_b: the second structure + * + */ + +static int glock_compare(const void *arg_a, const void *arg_b) +{ + struct gfs2_holder *gh_a = *(struct gfs2_holder **)arg_a; + struct gfs2_holder *gh_b = *(struct gfs2_holder **)arg_b; + struct lm_lockname *a = &gh_a->gh_gl->gl_name; + struct lm_lockname *b = &gh_b->gh_gl->gl_name; + int ret = 0; + + if (a->ln_number > b->ln_number) + ret = 1; + else if (a->ln_number < b->ln_number) + ret = -1; + else { + if (gh_a->gh_state == LM_ST_SHARED && + gh_b->gh_state == LM_ST_EXCLUSIVE) + ret = 1; + else if (!(gh_a->gh_flags & GL_LOCAL_EXCL) && + (gh_b->gh_flags & GL_LOCAL_EXCL)) + ret = 1; + } + + return ret; +} + +/** + * nq_m_sync - synchonously acquire more than one glock in deadlock free order + * @num_gh: the number of structures + * @ghs: an array of struct gfs2_holder structures + * + * Returns: 0 on success (all glocks acquired), + * errno on failure (no glocks acquired) + */ + +static int nq_m_sync(unsigned int num_gh, struct gfs2_holder *ghs, + struct gfs2_holder **p) +{ + unsigned int x; + int error = 0; + + for (x = 0; x < num_gh; x++) + p[x] = &ghs[x]; + + sort(p, num_gh, sizeof(struct gfs2_holder *), glock_compare, NULL); + + for (x = 0; x < num_gh; x++) { + p[x]->gh_flags &= ~(LM_FLAG_TRY | GL_ASYNC); + + error = gfs2_glock_nq(p[x]); + if (error) { + while (x--) + gfs2_glock_dq(p[x]); + break; + } + } + + return error; +} + +/** + * gfs2_glock_nq_m - acquire multiple glocks + * @num_gh: the number of structures + * @ghs: an array of struct gfs2_holder structures + * + * Figure out how big an impact this function has. Either: + * 1) Replace this code with code that calls gfs2_glock_prefetch() + * 2) Forget async stuff and just call nq_m_sync() + * 3) Leave it like it is + * + * Returns: 0 on success (all glocks acquired), + * errno on failure (no glocks acquired) + */ + +int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs) +{ + int *e; + unsigned int x; + int borked = 0, serious = 0; + int error = 0; + + if (!num_gh) + return 0; + + if (num_gh == 1) { + ghs->gh_flags &= ~(LM_FLAG_TRY | GL_ASYNC); + return gfs2_glock_nq(ghs); + } + + e = kcalloc(num_gh, sizeof(struct gfs2_holder *), GFP_KERNEL); + if (!e) + return -ENOMEM; + + for (x = 0; x < num_gh; x++) { + ghs[x].gh_flags |= LM_FLAG_TRY | GL_ASYNC; + error = gfs2_glock_nq(&ghs[x]); + if (error) { + borked = 1; + serious = error; + num_gh = x; + break; + } + } + + for (x = 0; x < num_gh; x++) { + error = e[x] = glock_wait_internal(&ghs[x]); + if (error) { + borked = 1; + if (error != GLR_TRYFAILED && error != GLR_CANCELED) + serious = error; + } + } + + if (!borked) { + kfree(e); + return 0; + } + + for (x = 0; x < num_gh; x++) + if (!e[x]) + gfs2_glock_dq(&ghs[x]); + + if (serious) + error = serious; + else { + for (x = 0; x < num_gh; x++) + gfs2_holder_reinit(ghs[x].gh_state, ghs[x].gh_flags, + &ghs[x]); + error = nq_m_sync(num_gh, ghs, (struct gfs2_holder **)e); + } + + kfree(e); + + return error; +} + +/** + * gfs2_glock_dq_m - release multiple glocks + * @num_gh: the number of structures + * @ghs: an array of struct gfs2_holder structures + * + */ + +void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs) +{ + unsigned int x; + + for (x = 0; x < num_gh; x++) + gfs2_glock_dq(&ghs[x]); +} + +/** + * gfs2_glock_dq_uninit_m - release multiple glocks + * @num_gh: the number of structures + * @ghs: an array of struct gfs2_holder structures + * + */ + +void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs) +{ + unsigned int x; + + for (x = 0; x < num_gh; x++) + gfs2_glock_dq_uninit(&ghs[x]); +} + +/** + * gfs2_glock_prefetch_num - prefetch a glock based on lock number + * @sdp: the filesystem + * @number: the lock number + * @glops: the glock operations for the type of glock + * @state: the state to acquire the glock in + * @flags: modifier flags for the aquisition + * + * Returns: errno + */ + +void gfs2_glock_prefetch_num(struct gfs2_sbd *sdp, uint64_t number, + struct gfs2_glock_operations *glops, + unsigned int state, int flags) +{ + struct gfs2_glock *gl; + int error; + + if (atomic_read(&sdp->sd_reclaim_count) < + gfs2_tune_get(sdp, gt_reclaim_limit)) { + error = gfs2_glock_get(sdp, number, glops, CREATE, &gl); + if (!error) { + gfs2_glock_prefetch(gl, state, flags); + gfs2_glock_put(gl); + } + } +} + +/** + * gfs2_lvb_hold - attach a LVB from a glock + * @gl: The glock in question + * + */ + +int gfs2_lvb_hold(struct gfs2_glock *gl) +{ + int error; + + gfs2_glmutex_lock(gl); + + if (!atomic_read(&gl->gl_lvb_count)) { + error = gfs2_lm_hold_lvb(gl->gl_sbd, gl->gl_lock, &gl->gl_lvb); + if (error) { + gfs2_glmutex_unlock(gl); + return error; + } + gfs2_glock_hold(gl); + } + atomic_inc(&gl->gl_lvb_count); + + gfs2_glmutex_unlock(gl); + + return 0; +} + +/** + * gfs2_lvb_unhold - detach a LVB from a glock + * @gl: The glock in question + * + */ + +void gfs2_lvb_unhold(struct gfs2_glock *gl) +{ + gfs2_glock_hold(gl); + gfs2_glmutex_lock(gl); + + gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count) > 0); + if (atomic_dec_and_test(&gl->gl_lvb_count)) { + gfs2_lm_unhold_lvb(gl->gl_sbd, gl->gl_lock, gl->gl_lvb); + gl->gl_lvb = NULL; + gfs2_glock_put(gl); + } + + gfs2_glmutex_unlock(gl); + gfs2_glock_put(gl); +} + +void gfs2_lvb_sync(struct gfs2_glock *gl) +{ + gfs2_glmutex_lock(gl); + + gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count)); + if (!gfs2_assert_warn(gl->gl_sbd, gfs2_glock_is_held_excl(gl))) + gfs2_lm_sync_lvb(gl->gl_sbd, gl->gl_lock, gl->gl_lvb); + + gfs2_glmutex_unlock(gl); +} + +static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name, + unsigned int state) +{ + struct gfs2_glock *gl; + + gl = gfs2_glock_find(sdp, name); + if (!gl) + return; + + if (gl->gl_ops->go_callback) + gl->gl_ops->go_callback(gl, state); + handle_callback(gl, state); + + spin_lock(&gl->gl_spin); + run_queue(gl); + spin_unlock(&gl->gl_spin); + + gfs2_glock_put(gl); +} + +/** + * gfs2_glock_cb - Callback used by locking module + * @fsdata: Pointer to the superblock + * @type: Type of callback + * @data: Type dependent data pointer + * + * Called by the locking module when it wants to tell us something. + * Either we need to drop a lock, one of our ASYNC requests completed, or + * a journal from another client needs to be recovered. + */ + +void gfs2_glock_cb(lm_fsdata_t *fsdata, unsigned int type, void *data) +{ + struct gfs2_sbd *sdp = (struct gfs2_sbd *)fsdata; + + atomic_inc(&sdp->sd_lm_callbacks); + + switch (type) { + case LM_CB_NEED_E: + blocking_cb(sdp, (struct lm_lockname *)data, LM_ST_UNLOCKED); + return; + + case LM_CB_NEED_D: + blocking_cb(sdp, (struct lm_lockname *)data, LM_ST_DEFERRED); + return; + + case LM_CB_NEED_S: + blocking_cb(sdp, (struct lm_lockname *)data, LM_ST_SHARED); + return; + + case LM_CB_ASYNC: { + struct lm_async_cb *async = (struct lm_async_cb *)data; + struct gfs2_glock *gl; + + gl = gfs2_glock_find(sdp, &async->lc_name); + if (gfs2_assert_warn(sdp, gl)) + return; + if (!gfs2_assert_warn(sdp, gl->gl_req_bh)) + gl->gl_req_bh(gl, async->lc_ret); + gfs2_glock_put(gl); + + return; + } + + case LM_CB_NEED_RECOVERY: + gfs2_jdesc_make_dirty(sdp, *(unsigned int *)data); + if (sdp->sd_recoverd_process) + wake_up_process(sdp->sd_recoverd_process); + return; + + case LM_CB_DROPLOCKS: + gfs2_gl_hash_clear(sdp, NO_WAIT); + gfs2_quota_scan(sdp); + return; + + default: + gfs2_assert_warn(sdp, 0); + return; + } +} + +/** + * gfs2_try_toss_inode - try to remove a particular inode struct from cache + * sdp: the filesystem + * inum: the inode number + * + */ + +void gfs2_try_toss_inode(struct gfs2_sbd *sdp, struct gfs2_inum *inum) +{ + struct gfs2_glock *gl; + struct gfs2_inode *ip; + int error; + + error = gfs2_glock_get(sdp, inum->no_addr, &gfs2_inode_glops, + NO_CREATE, &gl); + if (error || !gl) + return; + + if (!gfs2_glmutex_trylock(gl)) + goto out; + + ip = get_gl2ip(gl); + if (!ip) + goto out_unlock; + + if (atomic_read(&ip->i_count)) + goto out_unlock; + + gfs2_inode_destroy(ip); + + out_unlock: + gfs2_glmutex_unlock(gl); + + out: + gfs2_glock_put(gl); +} + +/** + * gfs2_iopen_go_callback - Try to kick the inode/vnode associated with an + * iopen glock from memory + * @io_gl: the iopen glock + * @state: the state into which the glock should be put + * + */ + +void gfs2_iopen_go_callback(struct gfs2_glock *io_gl, unsigned int state) +{ + struct gfs2_glock *i_gl; + + if (state != LM_ST_UNLOCKED) + return; + + spin_lock(&io_gl->gl_spin); + i_gl = get_gl2gl(io_gl); + if (i_gl) { + gfs2_glock_hold(i_gl); + spin_unlock(&io_gl->gl_spin); + } else { + spin_unlock(&io_gl->gl_spin); + return; + } + + if (gfs2_glmutex_trylock(i_gl)) { + struct gfs2_inode *ip = get_gl2ip(i_gl); + if (ip) { + gfs2_try_toss_vnode(ip); + gfs2_glmutex_unlock(i_gl); + gfs2_glock_schedule_for_reclaim(i_gl); + goto out; + } + gfs2_glmutex_unlock(i_gl); + } + + out: + gfs2_glock_put(i_gl); +} + +/** + * demote_ok - Check to see if it's ok to unlock a glock + * @gl: the glock + * + * Returns: 1 if it's ok + */ + +static int demote_ok(struct gfs2_glock *gl) +{ + struct gfs2_sbd *sdp = gl->gl_sbd; + struct gfs2_glock_operations *glops = gl->gl_ops; + int demote = 1; + + if (test_bit(GLF_STICKY, &gl->gl_flags)) + demote = 0; + else if (test_bit(GLF_PREFETCH, &gl->gl_flags)) + demote = time_after_eq(jiffies, + gl->gl_stamp + + gfs2_tune_get(sdp, gt_prefetch_secs) * HZ); + else if (glops->go_demote_ok) + demote = glops->go_demote_ok(gl); + + return demote; +} + +/** + * gfs2_glock_schedule_for_reclaim - Add a glock to the reclaim list + * @gl: the glock + * + */ + +void gfs2_glock_schedule_for_reclaim(struct gfs2_glock *gl) +{ + struct gfs2_sbd *sdp = gl->gl_sbd; + + spin_lock(&sdp->sd_reclaim_lock); + if (list_empty(&gl->gl_reclaim)) { + gfs2_glock_hold(gl); + list_add(&gl->gl_reclaim, &sdp->sd_reclaim_list); + atomic_inc(&sdp->sd_reclaim_count); + } + spin_unlock(&sdp->sd_reclaim_lock); + + wake_up(&sdp->sd_reclaim_wq); +} + +/** + * gfs2_reclaim_glock - process the next glock on the filesystem's reclaim list + * @sdp: the filesystem + * + * Called from gfs2_glockd() glock reclaim daemon, or when promoting a + * different glock and we notice that there are a lot of glocks in the + * reclaim list. + * + */ + +void gfs2_reclaim_glock(struct gfs2_sbd *sdp) +{ + struct gfs2_glock *gl; + + spin_lock(&sdp->sd_reclaim_lock); + if (list_empty(&sdp->sd_reclaim_list)) { + spin_unlock(&sdp->sd_reclaim_lock); + return; + } + gl = list_entry(sdp->sd_reclaim_list.next, + struct gfs2_glock, gl_reclaim); + list_del_init(&gl->gl_reclaim); + spin_unlock(&sdp->sd_reclaim_lock); + + atomic_dec(&sdp->sd_reclaim_count); + atomic_inc(&sdp->sd_reclaimed); + + if (gfs2_glmutex_trylock(gl)) { + if (gl->gl_ops == &gfs2_inode_glops) { + struct gfs2_inode *ip = get_gl2ip(gl); + if (ip && !atomic_read(&ip->i_count)) + gfs2_inode_destroy(ip); + } + if (queue_empty(gl, &gl->gl_holders) && + gl->gl_state != LM_ST_UNLOCKED && + demote_ok(gl)) + handle_callback(gl, LM_ST_UNLOCKED); + gfs2_glmutex_unlock(gl); + } + + gfs2_glock_put(gl); +} + +/** + * examine_bucket - Call a function for glock in a hash bucket + * @examiner: the function + * @sdp: the filesystem + * @bucket: the bucket + * + * Returns: 1 if the bucket has entries + */ + +static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, + struct gfs2_gl_hash_bucket *bucket) +{ + struct glock_plug plug; + struct list_head *tmp; + struct gfs2_glock *gl; + int entries; + + /* Add "plug" to end of bucket list, work back up list from there */ + memset(&plug.gl_flags, 0, sizeof(unsigned long)); + set_bit(GLF_PLUG, &plug.gl_flags); + + write_lock(&bucket->hb_lock); + list_add(&plug.gl_list, &bucket->hb_list); + write_unlock(&bucket->hb_lock); + + for (;;) { + write_lock(&bucket->hb_lock); + + for (;;) { + tmp = plug.gl_list.next; + + if (tmp == &bucket->hb_list) { + list_del(&plug.gl_list); + entries = !list_empty(&bucket->hb_list); + write_unlock(&bucket->hb_lock); + return entries; + } + gl = list_entry(tmp, struct gfs2_glock, gl_list); + + /* Move plug up list */ + list_move(&plug.gl_list, &gl->gl_list); + + if (test_bit(GLF_PLUG, &gl->gl_flags)) + continue; + + /* examiner() must glock_put() */ + gfs2_glock_hold(gl); + + break; + } + + write_unlock(&bucket->hb_lock); + + examiner(gl); + } +} + +/** + * scan_glock - look at a glock and see if we can reclaim it + * @gl: the glock to look at + * + */ + +static void scan_glock(struct gfs2_glock *gl) +{ + if (gfs2_glmutex_trylock(gl)) { + if (gl->gl_ops == &gfs2_inode_glops) { + struct gfs2_inode *ip = get_gl2ip(gl); + if (ip && !atomic_read(&ip->i_count)) + goto out_schedule; + } + if (queue_empty(gl, &gl->gl_holders) && + gl->gl_state != LM_ST_UNLOCKED && + demote_ok(gl)) + goto out_schedule; + + gfs2_glmutex_unlock(gl); + } + + gfs2_glock_put(gl); + + return; + + out_schedule: + gfs2_glmutex_unlock(gl); + gfs2_glock_schedule_for_reclaim(gl); + gfs2_glock_put(gl); +} + +/** + * gfs2_scand_internal - Look for glocks and inodes to toss from memory + * @sdp: the filesystem + * + */ + +void gfs2_scand_internal(struct gfs2_sbd *sdp) +{ + unsigned int x; + + for (x = 0; x < GFS2_GL_HASH_SIZE; x++) { + examine_bucket(scan_glock, sdp, &sdp->sd_gl_hash[x]); + cond_resched(); + } +} + +/** + * clear_glock - look at a glock and see if we can free it from glock cache + * @gl: the glock to look at + * + */ + +static void clear_glock(struct gfs2_glock *gl) +{ + struct gfs2_sbd *sdp = gl->gl_sbd; + int released; + + spin_lock(&sdp->sd_reclaim_lock); + if (!list_empty(&gl->gl_reclaim)) { + list_del_init(&gl->gl_reclaim); + atomic_dec(&sdp->sd_reclaim_count); + released = gfs2_glock_put(gl); + gfs2_assert(sdp, !released); + } + spin_unlock(&sdp->sd_reclaim_lock); + + if (gfs2_glmutex_trylock(gl)) { + if (gl->gl_ops == &gfs2_inode_glops) { + struct gfs2_inode *ip = get_gl2ip(gl); + if (ip && !atomic_read(&ip->i_count)) + gfs2_inode_destroy(ip); + } + if (queue_empty(gl, &gl->gl_holders) && + gl->gl_state != LM_ST_UNLOCKED) + handle_callback(gl, LM_ST_UNLOCKED); + + gfs2_glmutex_unlock(gl); + } + + gfs2_glock_put(gl); +} + +/** + * gfs2_gl_hash_clear - Empty out the glock hash table + * @sdp: the filesystem + * @wait: wait until it's all gone + * + * Called when unmounting the filesystem, or when inter-node lock manager + * requests DROPLOCKS because it is running out of capacity. + */ + +void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait) +{ + unsigned long t; + unsigned int x; + int cont; + + t = jiffies; + + for (;;) { + cont = 0; + + for (x = 0; x < GFS2_GL_HASH_SIZE; x++) + if (examine_bucket(clear_glock, sdp, + &sdp->sd_gl_hash[x])) + cont = 1; + + if (!wait || !cont) + break; + + if (time_after_eq(jiffies, + t + gfs2_tune_get(sdp, gt_stall_secs) * HZ)) { + fs_warn(sdp, "Unmount seems to be stalled. " + "Dumping lock state...\n"); + gfs2_dump_lockstate(sdp); + t = jiffies; + } + + /* invalidate_inodes() requires that the sb inodes list + not change, but an async completion callback for an + unlock can occur which does glock_put() which + can call iput() which will change the sb inodes list. + invalidate_inodes_mutex prevents glock_put()'s during + an invalidate_inodes() */ + + down(&sdp->sd_invalidate_inodes_mutex); + invalidate_inodes(sdp->sd_vfs); + up(&sdp->sd_invalidate_inodes_mutex); + yield(); + } +} + +/* + * Diagnostic routines to help debug distributed deadlock + */ + +/** + * dump_holder - print information about a glock holder + * @str: a string naming the type of holder + * @gh: the glock holder + * + * Returns: 0 on success, -ENOBUFS when we run out of space + */ + +static int dump_holder(char *str, struct gfs2_holder *gh) +{ + unsigned int x; + int error = -ENOBUFS; + + printk(" %s\n", str); + printk(" owner = %ld\n", + (gh->gh_owner) ? (long)gh->gh_owner->pid : -1); + printk(" gh_state = %u\n", gh->gh_state); + printk(" gh_flags ="); + for (x = 0; x < 32; x++) + if (gh->gh_flags & (1 << x)) + printk(" %u", x); + printk(" \n"); + printk(" error = %d\n", gh->gh_error); + printk(" gh_iflags ="); + for (x = 0; x < 32; x++) + if (test_bit(x, &gh->gh_iflags)) + printk(" %u", x); + printk(" \n"); + + error = 0; + + return error; +} + +/** + * dump_inode - print information about an inode + * @ip: the inode + * + * Returns: 0 on success, -ENOBUFS when we run out of space + */ + +static int dump_inode(struct gfs2_inode *ip) +{ + unsigned int x; + int error = -ENOBUFS; + + printk(" Inode:\n"); + printk(" num = %llu %llu\n", + ip->i_num.no_formal_ino, ip->i_num.no_addr); + printk(" type = %u\n", IF2DT(ip->i_di.di_mode)); + printk(" i_count = %d\n", atomic_read(&ip->i_count)); + printk(" i_flags ="); + for (x = 0; x < 32; x++) + if (test_bit(x, &ip->i_flags)) + printk(" %u", x); + printk(" \n"); + printk(" vnode = %s\n", (ip->i_vnode) ? "yes" : "no"); + + error = 0; + + return error; +} + +/** + * dump_glock - print information about a glock + * @gl: the glock + * @count: where we are in the buffer + * + * Returns: 0 on success, -ENOBUFS when we run out of space + */ + +static int dump_glock(struct gfs2_glock *gl) +{ + struct gfs2_holder *gh; + unsigned int x; + int error = -ENOBUFS; + + spin_lock(&gl->gl_spin); + + printk("Glock (%u, %llu)\n", + gl->gl_name.ln_type, + gl->gl_name.ln_number); + printk(" gl_flags ="); + for (x = 0; x < 32; x++) + if (test_bit(x, &gl->gl_flags)) + printk(" %u", x); + printk(" \n"); + printk(" gl_ref = %d\n", atomic_read(&gl->gl_ref.refcount)); + printk(" gl_state = %u\n", gl->gl_state); + printk(" req_gh = %s\n", (gl->gl_req_gh) ? "yes" : "no"); + printk(" req_bh = %s\n", (gl->gl_req_bh) ? "yes" : "no"); + printk(" lvb_count = %d\n", atomic_read(&gl->gl_lvb_count)); + printk(" object = %s\n", (gl->gl_object) ? "yes" : "no"); + printk(" le = %s\n", + (list_empty(&gl->gl_le.le_list)) ? "no" : "yes"); + printk(" reclaim = %s\n", + (list_empty(&gl->gl_reclaim)) ? "no" : "yes"); + if (gl->gl_aspace) + printk(" aspace = %lu\n", + gl->gl_aspace->i_mapping->nrpages); + else + printk(" aspace = no\n"); + printk(" ail = %d\n", atomic_read(&gl->gl_ail_count)); + if (gl->gl_req_gh) { + error = dump_holder("Request", gl->gl_req_gh); + if (error) + goto out; + } + list_for_each_entry(gh, &gl->gl_holders, gh_list) { + error = dump_holder("Holder", gh); + if (error) + goto out; + } + list_for_each_entry(gh, &gl->gl_waiters1, gh_list) { + error = dump_holder("Waiter1", gh); + if (error) + goto out; + } + list_for_each_entry(gh, &gl->gl_waiters2, gh_list) { + error = dump_holder("Waiter2", gh); + if (error) + goto out; + } + list_for_each_entry(gh, &gl->gl_waiters3, gh_list) { + error = dump_holder("Waiter3", gh); + if (error) + goto out; + } + if (gl->gl_ops == &gfs2_inode_glops && get_gl2ip(gl)) { + if (!test_bit(GLF_LOCK, &gl->gl_flags) && + list_empty(&gl->gl_holders)) { + error = dump_inode(get_gl2ip(gl)); + if (error) + goto out; + } else { + error = -ENOBUFS; + printk(" Inode: busy\n"); + } + } + + error = 0; + + out: + spin_unlock(&gl->gl_spin); + + return error; +} + +/** + * gfs2_dump_lockstate - print out the current lockstate + * @sdp: the filesystem + * @ub: the buffer to copy the information into + * + * If @ub is NULL, dump the lockstate to the console. + * + */ + +int gfs2_dump_lockstate(struct gfs2_sbd *sdp) +{ + struct gfs2_gl_hash_bucket *bucket; + struct gfs2_glock *gl; + unsigned int x; + int error = 0; + + for (x = 0; x < GFS2_GL_HASH_SIZE; x++) { + bucket = &sdp->sd_gl_hash[x]; + + read_lock(&bucket->hb_lock); + + list_for_each_entry(gl, &bucket->hb_list, gl_list) { + if (test_bit(GLF_PLUG, &gl->gl_flags)) + continue; + + error = dump_glock(gl); + if (error) + break; + } + + read_unlock(&bucket->hb_lock); + + if (error) + break; + } + + + return error; +} + -- cgit 1.2.3-korg From f55ab26a8f92a23988c3e6da28dae4741933a4e2 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Tue, 21 Feb 2006 12:51:39 +0000 Subject: [GFS2] Use mutices rather than semaphores As well as a number of minor bug fixes, this patch changes GFS to use mutices rather than semaphores. This results in better information in case there are any locking problems. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 8 ++++---- fs/gfs2/incore.h | 22 ++++++++++----------- fs/gfs2/inode.c | 12 ++++++------ fs/gfs2/log.c | 54 ++++++++++++++++++--------------------------------- fs/gfs2/log.h | 3 --- fs/gfs2/lops.c | 36 ++++++++++++++++++++++++++-------- fs/gfs2/meta_io.c | 2 +- fs/gfs2/ops_address.c | 1 - fs/gfs2/ops_file.c | 10 +++++----- fs/gfs2/ops_fstype.c | 18 ++++++++--------- fs/gfs2/ops_super.c | 4 ++-- fs/gfs2/quota.c | 16 +++++++-------- fs/gfs2/rgrp.c | 18 ++++++++--------- fs/gfs2/super.c | 20 +++++++++---------- fs/gfs2/sys.c | 4 ++-- fs/gfs2/trans.c | 4 ++-- fs/gfs2/unlinked.c | 4 ++-- 17 files changed, 118 insertions(+), 118 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 321945fde12d9d..4df78ecfeeb3ae 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -149,7 +149,7 @@ int gfs2_glock_put(struct gfs2_glock *gl) struct gfs2_gl_hash_bucket *bucket = gl->gl_bucket; int rv = 0; - down(&sdp->sd_invalidate_inodes_mutex); + mutex_lock(&sdp->sd_invalidate_inodes_mutex); write_lock(&bucket->hb_lock); if (kref_put(&gl->gl_ref, kill_glock)) { @@ -161,7 +161,7 @@ int gfs2_glock_put(struct gfs2_glock *gl) } write_unlock(&bucket->hb_lock); out: - up(&sdp->sd_invalidate_inodes_mutex); + mutex_unlock(&sdp->sd_invalidate_inodes_mutex); return rv; } @@ -2312,9 +2312,9 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait) invalidate_inodes_mutex prevents glock_put()'s during an invalidate_inodes() */ - down(&sdp->sd_invalidate_inodes_mutex); + mutex_lock(&sdp->sd_invalidate_inodes_mutex); invalidate_inodes(sdp->sd_vfs); - up(&sdp->sd_invalidate_inodes_mutex); + mutex_unlock(&sdp->sd_invalidate_inodes_mutex); yield(); } } diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index e43a0475d0d842..7fe422537ff083 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -88,7 +88,7 @@ struct gfs2_rgrpd { uint64_t rd_rg_vn; struct gfs2_bitmap *rd_bits; unsigned int rd_bh_count; - struct semaphore rd_mutex; + struct mutex rd_mutex; uint32_t rd_free_clone; struct gfs2_log_element rd_le; uint32_t rd_last_alloc_data; @@ -277,7 +277,7 @@ enum { struct gfs2_file { unsigned long f_flags; /* GFF_... */ - struct semaphore f_fl_mutex; + struct mutex f_fl_mutex; struct gfs2_holder f_fl_gh; struct gfs2_inode *f_inode; @@ -510,7 +510,7 @@ struct gfs2_sbd { struct gfs2_holder sd_live_gh; struct gfs2_glock *sd_rename_gl; struct gfs2_glock *sd_trans_gl; - struct semaphore sd_invalidate_inodes_mutex; + struct mutex sd_invalidate_inodes_mutex; /* Inode Stuff */ @@ -528,12 +528,12 @@ struct gfs2_sbd { /* Inum stuff */ - struct semaphore sd_inum_mutex; + struct mutex sd_inum_mutex; /* StatFS stuff */ spinlock_t sd_statfs_spin; - struct semaphore sd_statfs_mutex; + struct mutex sd_statfs_mutex; struct gfs2_statfs_change sd_statfs_master; struct gfs2_statfs_change sd_statfs_local; unsigned long sd_statfs_sync_time; @@ -542,7 +542,7 @@ struct gfs2_sbd { uint64_t sd_rindex_vn; spinlock_t sd_rindex_spin; - struct semaphore sd_rindex_mutex; + struct mutex sd_rindex_mutex; struct list_head sd_rindex_list; struct list_head sd_rindex_mru_list; struct list_head sd_rindex_recent_list; @@ -553,7 +553,7 @@ struct gfs2_sbd { struct list_head sd_jindex_list; spinlock_t sd_jindex_spin; - struct semaphore sd_jindex_mutex; + struct mutex sd_jindex_mutex; unsigned int sd_journals; unsigned long sd_jindex_refresh_time; @@ -581,7 +581,7 @@ struct gfs2_sbd { struct list_head sd_unlinked_list; atomic_t sd_unlinked_count; spinlock_t sd_unlinked_spin; - struct semaphore sd_unlinked_mutex; + struct mutex sd_unlinked_mutex; unsigned int sd_unlinked_slots; unsigned int sd_unlinked_chunks; @@ -592,7 +592,7 @@ struct gfs2_sbd { struct list_head sd_quota_list; atomic_t sd_quota_count; spinlock_t sd_quota_spin; - struct semaphore sd_quota_mutex; + struct mutex sd_quota_mutex; unsigned int sd_quota_slots; unsigned int sd_quota_chunks; @@ -637,7 +637,7 @@ struct gfs2_sbd { int sd_log_idle; unsigned long sd_log_flush_time; - struct semaphore sd_log_flush_lock; + struct mutex sd_log_flush_lock; struct list_head sd_log_flush_list; unsigned int sd_log_flush_head; @@ -659,7 +659,7 @@ struct gfs2_sbd { /* For quiescing the filesystem */ struct gfs2_holder sd_freeze_gh; - struct semaphore sd_freeze_lock; + struct mutex sd_freeze_lock; unsigned int sd_freeze_count; /* Counters */ diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 2a00b96eac01bb..30ca82a1addf03 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -782,11 +782,11 @@ static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino) error = gfs2_trans_begin(sdp, RES_DINODE, 0); if (error) return error; - down(&sdp->sd_inum_mutex); + mutex_lock(&sdp->sd_inum_mutex); error = gfs2_meta_inode_buffer(ip, &bh); if (error) { - up(&sdp->sd_inum_mutex); + mutex_unlock(&sdp->sd_inum_mutex); gfs2_trans_end(sdp); return error; } @@ -800,14 +800,14 @@ static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino) gfs2_inum_range_out(&ir, bh->b_data + sizeof(struct gfs2_dinode)); brelse(bh); - up(&sdp->sd_inum_mutex); + mutex_unlock(&sdp->sd_inum_mutex); gfs2_trans_end(sdp); return 0; } brelse(bh); - up(&sdp->sd_inum_mutex); + mutex_unlock(&sdp->sd_inum_mutex); gfs2_trans_end(sdp); return 1; @@ -829,7 +829,7 @@ static int pick_formal_ino_2(struct gfs2_sbd *sdp, uint64_t *formal_ino) error = gfs2_trans_begin(sdp, 2 * RES_DINODE, 0); if (error) goto out; - down(&sdp->sd_inum_mutex); + mutex_lock(&sdp->sd_inum_mutex); error = gfs2_meta_inode_buffer(ip, &bh); if (error) @@ -869,7 +869,7 @@ static int pick_formal_ino_2(struct gfs2_sbd *sdp, uint64_t *formal_ino) brelse(bh); out_end_trans: - up(&sdp->sd_inum_mutex); + mutex_unlock(&sdp->sd_inum_mutex); gfs2_trans_end(sdp); out: diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 49190a29dd4f0a..e6acb41332e703 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -23,29 +23,16 @@ #define PULL 1 -static inline int is_done(struct gfs2_sbd *sdp, atomic_t *a) -{ - int done; - gfs2_log_lock(sdp); - done = atomic_read(a) ? 0 : 1; - gfs2_log_unlock(sdp); - return done; -} - static void do_lock_wait(struct gfs2_sbd *sdp, wait_queue_head_t *wq, atomic_t *a) { - gfs2_log_unlock(sdp); - wait_event(*wq, is_done(sdp, a)); - gfs2_log_lock(sdp); + wait_event(*wq, atomic_read(a) ? 0 : 1); } static void lock_for_trans(struct gfs2_sbd *sdp) { - gfs2_log_lock(sdp); do_lock_wait(sdp, &sdp->sd_log_trans_wq, &sdp->sd_log_flush_count); atomic_inc(&sdp->sd_log_trans_count); - gfs2_log_unlock(sdp); } static void unlock_from_trans(struct gfs2_sbd *sdp) @@ -55,15 +42,13 @@ static void unlock_from_trans(struct gfs2_sbd *sdp) wake_up(&sdp->sd_log_flush_wq); } -void gfs2_lock_for_flush(struct gfs2_sbd *sdp) +static void gfs2_lock_for_flush(struct gfs2_sbd *sdp) { - gfs2_log_lock(sdp); atomic_inc(&sdp->sd_log_flush_count); do_lock_wait(sdp, &sdp->sd_log_flush_wq, &sdp->sd_log_trans_count); - gfs2_log_unlock(sdp); } -void gfs2_unlock_from_flush(struct gfs2_sbd *sdp) +static void gfs2_unlock_from_flush(struct gfs2_sbd *sdp) { gfs2_assert_warn(sdp, atomic_read(&sdp->sd_log_flush_count)); if (atomic_dec_and_test(&sdp->sd_log_flush_count)) @@ -209,7 +194,6 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks) for (;;) { gfs2_log_lock(sdp); - if (list_empty(&list)) { list_add_tail(&list, &sdp->sd_log_blks_list); while (sdp->sd_log_blks_list.next != &list) { @@ -225,7 +209,6 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks) set_current_state(TASK_RUNNING); } } - /* Never give away the last block so we can always pull the tail if we need to. */ if (sdp->sd_log_blks_free > blks) { @@ -237,14 +220,12 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks) } gfs2_log_unlock(sdp); - gfs2_ail1_empty(sdp, 0); gfs2_log_flush(sdp); if (try++) gfs2_ail1_start(sdp, 0); } - lock_for_trans(sdp); return 0; @@ -512,22 +493,26 @@ void gfs2_log_flush_i(struct gfs2_sbd *sdp, struct gfs2_glock *gl) ai = kzalloc(sizeof(struct gfs2_ail), GFP_NOFS | __GFP_NOFAIL); INIT_LIST_HEAD(&ai->ai_ail1_list); INIT_LIST_HEAD(&ai->ai_ail2_list); - gfs2_lock_for_flush(sdp); - down(&sdp->sd_log_flush_lock); + + if (gl) { + gfs2_log_lock(sdp); + if (list_empty(&gl->gl_le.le_list)) { + gfs2_log_unlock(sdp); + gfs2_unlock_from_flush(sdp); + kfree(ai); + return; + } + gfs2_log_unlock(sdp); + } + + mutex_lock(&sdp->sd_log_flush_lock); gfs2_assert_withdraw(sdp, sdp->sd_log_num_buf == sdp->sd_log_commited_buf); gfs2_assert_withdraw(sdp, sdp->sd_log_num_revoke == sdp->sd_log_commited_revoke); - if (gl && list_empty(&gl->gl_le.le_list)) { - up(&sdp->sd_log_flush_lock); - gfs2_unlock_from_flush(sdp); - kfree(ai); - return; - } - sdp->sd_log_flush_head = sdp->sd_log_head; sdp->sd_log_flush_wrapped = 0; ai->ai_first = sdp->sd_log_flush_head; @@ -538,7 +523,6 @@ void gfs2_log_flush_i(struct gfs2_sbd *sdp, struct gfs2_glock *gl) else if (sdp->sd_log_tail != current_tail(sdp) && !sdp->sd_log_idle) log_write_header(sdp, 0, PULL); lops_after_commit(sdp, ai); - sdp->sd_log_head = sdp->sd_log_flush_head; if (sdp->sd_log_flush_wrapped) sdp->sd_log_wraps++; @@ -554,7 +538,7 @@ void gfs2_log_flush_i(struct gfs2_sbd *sdp, struct gfs2_glock *gl) } gfs2_log_unlock(sdp); - up(&sdp->sd_log_flush_lock); + mutex_unlock(&sdp->sd_log_flush_lock); sdp->sd_vfs->s_dirt = 0; gfs2_unlock_from_flush(sdp); @@ -627,7 +611,7 @@ void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) void gfs2_log_shutdown(struct gfs2_sbd *sdp) { - down(&sdp->sd_log_flush_lock); + mutex_lock(&sdp->sd_log_flush_lock); gfs2_assert_withdraw(sdp, !atomic_read(&sdp->sd_log_trans_count)); gfs2_assert_withdraw(sdp, !sdp->sd_log_blks_reserved); @@ -654,6 +638,6 @@ void gfs2_log_shutdown(struct gfs2_sbd *sdp) sdp->sd_log_wraps++; sdp->sd_log_tail = sdp->sd_log_head; - up(&sdp->sd_log_flush_lock); + mutex_unlock(&sdp->sd_log_flush_lock); } diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h index 4413cda8115470..e7a6a65c530f32 100644 --- a/fs/gfs2/log.h +++ b/fs/gfs2/log.h @@ -42,9 +42,6 @@ static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp, sdp->sd_log_head = sdp->sd_log_tail = value; } -void gfs2_lock_for_flush(struct gfs2_sbd *sdp); -void gfs2_unlock_from_flush(struct gfs2_sbd *sdp); - unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct, unsigned int ssize); diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 23be00141901b7..5e7e7d91fc5ee3 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -502,7 +502,8 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) unsigned int total_dbuf = sdp->sd_log_num_databuf; unsigned int total_jdata = sdp->sd_log_num_jdata; unsigned int num, n; - __be64 *ptr; + __be64 *ptr = NULL; + unsigned i; offset += (2*sizeof(__be64) - 1); offset &= ~(2*sizeof(__be64) - 1); @@ -513,14 +514,17 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) * Start writing ordered buffers, write journaled buffers * into the log along with a header */ + gfs2_log_lock(sdp); + /* printk(KERN_INFO "locked in lops databuf_before_commit\n"); */ bd2 = bd1 = list_prepare_entry(bd1, &sdp->sd_log_le_databuf, bd_le.le_list); while(total_dbuf) { num = total_jdata; if (num > limit) num = limit; + /* printk(KERN_INFO "total_dbuf=%u num=%u\n", total_dbuf, num); */ n = 0; + i = 0; list_for_each_entry_safe_continue(bd1, bdt, &sdp->sd_log_le_databuf, bd_le.le_list) { - gfs2_log_lock(sdp); /* An ordered write buffer */ if (bd1->bd_bh && !buffer_pinned(bd1->bd_bh)) { list_move(&bd1->bd_le.le_list, &started); @@ -531,20 +535,28 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) total_dbuf--; if (bd1->bd_bh) { get_bh(bd1->bd_bh); - gfs2_log_unlock(sdp); if (buffer_dirty(bd1->bd_bh)) { + gfs2_log_unlock(sdp); wait_on_buffer(bd1->bd_bh); ll_rw_block(WRITE, 1, &bd1->bd_bh); + gfs2_log_lock(sdp); } brelse(bd1->bd_bh); + /* printk(KERN_INFO "db write %p\n", bd1); */ + if (++i > 100000) { + printk(KERN_INFO "looping bd1=%p bdt=%p eol=%p started=%p\n", bd1, bdt, &sdp->sd_log_le_databuf, &started); + dump_stack(); + BUG(); + } continue; } - gfs2_log_unlock(sdp); + /* printk(KERN_INFO "db skip\n"); */ continue; } else if (bd1->bd_bh) { /* A journaled buffer */ int magic; gfs2_log_unlock(sdp); - /* printk(KERN_INFO "journaled buffer\n"); */ + printk(KERN_INFO "journaled buffer %p\n", bd1->bd_bh); + printk(KERN_INFO "%lu %u %p %p\n", bd1->bd_bh->b_blocknr, bd1->bd_bh->b_size, bd1->bd_bh->b_data, bd1->bd_bh->b_page); if (!bh) { bh = gfs2_log_get_buf(sdp); ld = (struct gfs2_log_descriptor *)bh->b_data; @@ -558,16 +570,21 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) ld->ld_data2 = cpu_to_be32(0); memset(ld->ld_reserved, 0, sizeof(ld->ld_reserved)); } + /* printk(KERN_INFO "check_magic\n"); */ magic = gfs2_check_magic(bd1->bd_bh); + /* printk(KERN_INFO "write data\n"); */ *ptr++ = cpu_to_be64(bd1->bd_bh->b_blocknr); *ptr++ = cpu_to_be64((__u64)magic); + /* printk(KERN_INFO "mark escaped or not\n"); */ clear_buffer_escaped(bd1->bd_bh); if (unlikely(magic != 0)) set_buffer_escaped(bd1->bd_bh); + gfs2_log_lock(sdp); if (n++ > num) break; } } + gfs2_log_unlock(sdp); if (bh) { set_buffer_dirty(bh); ll_rw_block(WRITE, 1, &bh); @@ -575,10 +592,12 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) } n = 0; /* printk(KERN_INFO "totals2: jdata=%u dbuf=%u\n", total_jdata, total_dbuf); */ + gfs2_log_lock(sdp); list_for_each_entry_continue(bd2, &sdp->sd_log_le_databuf, bd_le.le_list) { if (!bd2->bd_bh) continue; /* copy buffer if it needs escaping */ + gfs2_log_unlock(sdp); if (unlikely(buffer_escaped(bd2->bd_bh))) { void *kaddr; struct page *page = bd2->bd_bh->b_page; @@ -592,6 +611,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) } set_buffer_dirty(bh); ll_rw_block(WRITE, 1, &bh); + gfs2_log_lock(sdp); if (++n >= num) break; } @@ -599,6 +619,8 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) total_dbuf -= num; total_jdata -= num; } + gfs2_log_unlock(sdp); + /* printk(KERN_INFO "wait on ordered data buffers\n"); */ /* Wait on all ordered buffers */ while (!list_empty(&started)) { @@ -701,12 +723,10 @@ static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) while (!list_empty(head)) { bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list); - list_del_init(&bd->bd_le.le_list); + list_del(&bd->bd_le.le_list); sdp->sd_log_num_databuf--; sdp->sd_log_num_jdata--; gfs2_unpin(sdp, bd->bd_bh, ai); - brelse(bd->bd_bh); - kfree(bd); } gfs2_assert_warn(sdp, !sdp->sd_log_num_databuf); gfs2_assert_warn(sdp, !sdp->sd_log_num_jdata); diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index ef58d43b67eeb8..8fba8430675506 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -556,7 +556,7 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh, int meta return; } - bd = kmem_cache_alloc(gfs2_bufdata_cachep, GFP_KERNEL | __GFP_NOFAIL), + bd = kmem_cache_alloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL), atomic_inc(&gl->gl_sbd->sd_bufdata_count); memset(bd, 0, sizeof(struct gfs2_bufdata)); diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 1ccc264268214b..c719a2a40698e6 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -189,7 +189,6 @@ static int gfs2_writepage(struct page *page, struct writeback_control *wbc) gfs2_page_add_databufs(ip, page, 0, sdp->sd_vfs->s_blocksize-1); done_trans = 1; } - error = block_write_full_page(page, get_block_noalloc, wbc); if (done_trans) gfs2_trans_end(sdp); diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index b8603783229983..cf2e26e072455e 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c @@ -688,7 +688,7 @@ static int gfs2_open(struct inode *inode, struct file *file) if (!fp) return -ENOMEM; - init_MUTEX(&fp->f_fl_mutex); + mutex_init(&fp->f_fl_mutex); fp->f_inode = ip; fp->f_vfile = file; @@ -858,7 +858,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; flags = ((IS_SETLKW(cmd)) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE; - down(&fp->f_fl_mutex); + mutex_lock(&fp->f_fl_mutex); gl = fl_gh->gh_gl; if (gl) { @@ -890,7 +890,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) } out: - up(&fp->f_fl_mutex); + mutex_unlock(&fp->f_fl_mutex); return error; } @@ -900,11 +900,11 @@ static void do_unflock(struct file *file, struct file_lock *fl) struct gfs2_file *fp = get_v2fp(file); struct gfs2_holder *fl_gh = &fp->f_fl_gh; - down(&fp->f_fl_mutex); + mutex_lock(&fp->f_fl_mutex); flock_lock_file_wait(file, fl); if (fl_gh->gh_gl) gfs2_glock_dq_uninit(fl_gh); - up(&fp->f_fl_mutex); + mutex_unlock(&fp->f_fl_mutex); } /** diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 80d5582d9d9b88..751178ab497c8a 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -59,29 +59,29 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb) INIT_LIST_HEAD(&sdp->sd_reclaim_list); spin_lock_init(&sdp->sd_reclaim_lock); init_waitqueue_head(&sdp->sd_reclaim_wq); - init_MUTEX(&sdp->sd_invalidate_inodes_mutex); + mutex_init(&sdp->sd_invalidate_inodes_mutex); - init_MUTEX(&sdp->sd_inum_mutex); + mutex_init(&sdp->sd_inum_mutex); spin_lock_init(&sdp->sd_statfs_spin); - init_MUTEX(&sdp->sd_statfs_mutex); + mutex_init(&sdp->sd_statfs_mutex); spin_lock_init(&sdp->sd_rindex_spin); - init_MUTEX(&sdp->sd_rindex_mutex); + mutex_init(&sdp->sd_rindex_mutex); INIT_LIST_HEAD(&sdp->sd_rindex_list); INIT_LIST_HEAD(&sdp->sd_rindex_mru_list); INIT_LIST_HEAD(&sdp->sd_rindex_recent_list); INIT_LIST_HEAD(&sdp->sd_jindex_list); spin_lock_init(&sdp->sd_jindex_spin); - init_MUTEX(&sdp->sd_jindex_mutex); + mutex_init(&sdp->sd_jindex_mutex); INIT_LIST_HEAD(&sdp->sd_unlinked_list); spin_lock_init(&sdp->sd_unlinked_spin); - init_MUTEX(&sdp->sd_unlinked_mutex); + mutex_init(&sdp->sd_unlinked_mutex); INIT_LIST_HEAD(&sdp->sd_quota_list); spin_lock_init(&sdp->sd_quota_spin); - init_MUTEX(&sdp->sd_quota_mutex); + mutex_init(&sdp->sd_quota_mutex); spin_lock_init(&sdp->sd_log_lock); init_waitqueue_head(&sdp->sd_log_trans_wq); @@ -99,12 +99,12 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb) INIT_LIST_HEAD(&sdp->sd_ail1_list); INIT_LIST_HEAD(&sdp->sd_ail2_list); - init_MUTEX(&sdp->sd_log_flush_lock); + mutex_init(&sdp->sd_log_flush_lock); INIT_LIST_HEAD(&sdp->sd_log_flush_list); INIT_LIST_HEAD(&sdp->sd_revoke_list); - init_MUTEX(&sdp->sd_freeze_lock); + mutex_init(&sdp->sd_freeze_lock); return sdp; } diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index e06ef8dbd4d3bf..9130d0d0df3ce2 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -74,10 +74,10 @@ static void gfs2_put_super(struct super_block *sb) /* Unfreeze the filesystem, if we need to */ - down(&sdp->sd_freeze_lock); + mutex_lock(&sdp->sd_freeze_lock); if (sdp->sd_freeze_count) gfs2_glock_dq_uninit(&sdp->sd_freeze_gh); - up(&sdp->sd_freeze_lock); + mutex_unlock(&sdp->sd_freeze_lock); kthread_stop(sdp->sd_inoded_process); kthread_stop(sdp->sd_quotad_process); diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 7b5573946f1909..c0352cf330a344 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -251,10 +251,10 @@ static int bh_get(struct gfs2_quota_data *qd) struct buffer_head *bh; int error; - down(&sdp->sd_quota_mutex); + mutex_lock(&sdp->sd_quota_mutex); if (qd->qd_bh_count++) { - up(&sdp->sd_quota_mutex); + mutex_unlock(&sdp->sd_quota_mutex); return 0; } @@ -276,7 +276,7 @@ static int bh_get(struct gfs2_quota_data *qd) (bh->b_data + sizeof(struct gfs2_meta_header) + offset * sizeof(struct gfs2_quota_change)); - up(&sdp->sd_quota_mutex); + mutex_lock(&sdp->sd_quota_mutex); return 0; @@ -285,7 +285,7 @@ static int bh_get(struct gfs2_quota_data *qd) fail: qd->qd_bh_count--; - up(&sdp->sd_quota_mutex); + mutex_unlock(&sdp->sd_quota_mutex); return error; } @@ -293,14 +293,14 @@ static void bh_put(struct gfs2_quota_data *qd) { struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; - down(&sdp->sd_quota_mutex); + mutex_lock(&sdp->sd_quota_mutex); gfs2_assert(sdp, qd->qd_bh_count); if (!--qd->qd_bh_count) { brelse(qd->qd_bh); qd->qd_bh = NULL; qd->qd_bh_qc = NULL; } - up(&sdp->sd_quota_mutex); + mutex_unlock(&sdp->sd_quota_mutex); } static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp) @@ -529,7 +529,7 @@ static void do_qc(struct gfs2_quota_data *qd, int64_t change) struct gfs2_quota_change *qc = qd->qd_bh_qc; int64_t x; - down(&sdp->sd_quota_mutex); + mutex_lock(&sdp->sd_quota_mutex); gfs2_trans_add_bh(ip->i_gl, qd->qd_bh, 1); if (!test_bit(QDF_CHANGE, &qd->qd_flags)) { @@ -560,7 +560,7 @@ static void do_qc(struct gfs2_quota_data *qd, int64_t change) slot_hold(qd); } - up(&sdp->sd_quota_mutex); + mutex_unlock(&sdp->sd_quota_mutex); } /** diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 758cc565813a0a..2e69e5cda9677a 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -182,9 +182,9 @@ static void clear_rgrpdi(struct gfs2_sbd *sdp) void gfs2_clear_rgrpd(struct gfs2_sbd *sdp) { - down(&sdp->sd_rindex_mutex); + mutex_lock(&sdp->sd_rindex_mutex); clear_rgrpdi(sdp); - up(&sdp->sd_rindex_mutex); + mutex_unlock(&sdp->sd_rindex_mutex); } /** @@ -301,7 +301,7 @@ static int gfs2_ri_update(struct gfs2_inode *ip) if (!rgd) goto fail; - init_MUTEX(&rgd->rd_mutex); + mutex_init(&rgd->rd_mutex); lops_init_le(&rgd->rd_le, &gfs2_rg_lops); rgd->rd_sbd = sdp; @@ -363,13 +363,13 @@ int gfs2_rindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ri_gh) /* Read new copy from disk if we don't have the latest */ if (sdp->sd_rindex_vn != gl->gl_vn) { - down(&sdp->sd_rindex_mutex); + mutex_lock(&sdp->sd_rindex_mutex); if (sdp->sd_rindex_vn != gl->gl_vn) { error = gfs2_ri_update(ip); if (error) gfs2_glock_dq_uninit(ri_gh); } - up(&sdp->sd_rindex_mutex); + mutex_unlock(&sdp->sd_rindex_mutex); } return error; @@ -394,13 +394,13 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) unsigned int x, y; int error; - down(&rgd->rd_mutex); + mutex_lock(&rgd->rd_mutex); spin_lock(&sdp->sd_rindex_spin); if (rgd->rd_bh_count) { rgd->rd_bh_count++; spin_unlock(&sdp->sd_rindex_spin); - up(&rgd->rd_mutex); + mutex_unlock(&rgd->rd_mutex); return 0; } spin_unlock(&sdp->sd_rindex_spin); @@ -436,7 +436,7 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) rgd->rd_bh_count++; spin_unlock(&sdp->sd_rindex_spin); - up(&rgd->rd_mutex); + mutex_unlock(&rgd->rd_mutex); return 0; @@ -447,7 +447,7 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) bi->bi_bh = NULL; gfs2_assert_warn(sdp, !bi->bi_clone); } - up(&rgd->rd_mutex); + mutex_unlock(&rgd->rd_mutex); return error; } diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 9b5c31952c5da0..be80771c414d25 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -279,7 +279,7 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh) name.name = buf; - down(&sdp->sd_jindex_mutex); + mutex_lock(&sdp->sd_jindex_mutex); for (;;) { error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, @@ -317,7 +317,7 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh) spin_unlock(&sdp->sd_jindex_spin); } - up(&sdp->sd_jindex_mutex); + mutex_unlock(&sdp->sd_jindex_mutex); return error; } @@ -608,9 +608,9 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free, if (error) return; - down(&sdp->sd_statfs_mutex); + mutex_lock(&sdp->sd_statfs_mutex); gfs2_trans_add_bh(l_ip->i_gl, l_bh, 1); - up(&sdp->sd_statfs_mutex); + mutex_unlock(&sdp->sd_statfs_mutex); spin_lock(&sdp->sd_statfs_spin); l_sc->sc_total += total; @@ -659,9 +659,9 @@ int gfs2_statfs_sync(struct gfs2_sbd *sdp) if (error) goto out_bh2; - down(&sdp->sd_statfs_mutex); + mutex_lock(&sdp->sd_statfs_mutex); gfs2_trans_add_bh(l_ip->i_gl, l_bh, 1); - up(&sdp->sd_statfs_mutex); + mutex_unlock(&sdp->sd_statfs_mutex); spin_lock(&sdp->sd_statfs_spin); m_sc->sc_total += l_sc->sc_total; @@ -910,7 +910,7 @@ int gfs2_freeze_fs(struct gfs2_sbd *sdp) { int error = 0; - down(&sdp->sd_freeze_lock); + mutex_lock(&sdp->sd_freeze_lock); if (!sdp->sd_freeze_count++) { error = gfs2_lock_fs_check_clean(sdp, &sdp->sd_freeze_gh); @@ -918,7 +918,7 @@ int gfs2_freeze_fs(struct gfs2_sbd *sdp) sdp->sd_freeze_count--; } - up(&sdp->sd_freeze_lock); + mutex_unlock(&sdp->sd_freeze_lock); return error; } @@ -935,11 +935,11 @@ int gfs2_freeze_fs(struct gfs2_sbd *sdp) void gfs2_unfreeze_fs(struct gfs2_sbd *sdp) { - down(&sdp->sd_freeze_lock); + mutex_lock(&sdp->sd_freeze_lock); if (sdp->sd_freeze_count && !--sdp->sd_freeze_count) gfs2_glock_dq_uninit(&sdp->sd_freeze_gh); - up(&sdp->sd_freeze_lock); + mutex_unlock(&sdp->sd_freeze_lock); } diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index 75e9a3231b8f32..c5984351e4d8da 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c @@ -41,9 +41,9 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf) { unsigned int count; - down(&sdp->sd_freeze_lock); + mutex_lock(&sdp->sd_freeze_lock); count = sdp->sd_freeze_count; - up(&sdp->sd_freeze_lock); + mutex_unlock(&sdp->sd_freeze_lock); return sprintf(buf, "%u\n", count); } diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index 104e664fa182d2..0a0ea70eac4c69 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -33,7 +33,7 @@ int gfs2_trans_begin_i(struct gfs2_sbd *sdp, unsigned int blocks, return -EINVAL; } - tr = kzalloc(sizeof(struct gfs2_trans), GFP_KERNEL); + tr = kzalloc(sizeof(struct gfs2_trans), GFP_NOFS); if (!tr) return -ENOMEM; @@ -51,7 +51,7 @@ int gfs2_trans_begin_i(struct gfs2_sbd *sdp, unsigned int blocks, error = -ENOMEM; tr->tr_t_gh = gfs2_holder_get(sdp->sd_trans_gl, LM_ST_SHARED, - GL_NEVER_RECURSE, GFP_KERNEL); + GL_NEVER_RECURSE, GFP_NOFS); if (!tr->tr_t_gh) goto fail; diff --git a/fs/gfs2/unlinked.c b/fs/gfs2/unlinked.c index 405b91b0295d86..e92a3a11815ba8 100644 --- a/fs/gfs2/unlinked.c +++ b/fs/gfs2/unlinked.c @@ -46,12 +46,12 @@ static int munge_ondisk(struct gfs2_sbd *sdp, unsigned int slot, goto out; } - down(&sdp->sd_unlinked_mutex); + mutex_lock(&sdp->sd_unlinked_mutex); gfs2_trans_add_bh(ip->i_gl, bh, 1); gfs2_unlinked_tag_out(ut, bh->b_data + sizeof(struct gfs2_meta_header) + offset * sizeof(struct gfs2_unlinked_tag)); - up(&sdp->sd_unlinked_mutex); + mutex_unlock(&sdp->sd_unlinked_mutex); out: brelse(bh); -- cgit 1.2.3-korg From 6a6b3d018f4781f108d170f2181281a3c5589dc8 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 23 Feb 2006 10:11:47 +0000 Subject: [GFS2] Patch to remove stats gathering from GFS2 Signed-off-by: David Teigland Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 23 ++-------------- fs/gfs2/incore.h | 20 -------------- fs/gfs2/log.c | 4 --- fs/gfs2/meta_io.c | 3 --- fs/gfs2/ops_address.c | 12 --------- fs/gfs2/ops_dentry.c | 2 -- fs/gfs2/ops_export.c | 12 --------- fs/gfs2/ops_file.c | 29 ++------------------ fs/gfs2/ops_inode.c | 36 ------------------------- fs/gfs2/ops_super.c | 17 ------------ fs/gfs2/ops_vm.c | 4 --- fs/gfs2/sys.c | 74 +++++---------------------------------------------- 12 files changed, 10 insertions(+), 226 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 4df78ecfeeb3ae..cf1dc17faf4f4d 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -106,8 +106,6 @@ static void glock_free(struct gfs2_glock *gl) gfs2_aspace_put(aspace); kmem_cache_free(gfs2_glock_cachep, gl); - - atomic_dec(&sdp->sd_glock_count); } /** @@ -316,8 +314,6 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, if (error) goto fail_aspace; - atomic_inc(&sdp->sd_glock_count); - write_lock(&bucket->hb_lock); tmp = search_bucket(bucket, &name); if (tmp) { @@ -836,13 +832,10 @@ static void state_change(struct gfs2_glock *gl, unsigned int new_state) held2 = (new_state != LM_ST_UNLOCKED); if (held1 != held2) { - if (held2) { - atomic_inc(&sdp->sd_glock_held_count); + if (held2) gfs2_glock_hold(gl); - } else { - atomic_dec(&sdp->sd_glock_held_count); + else gfs2_glock_put(gl); - } } gl->gl_state = new_state; @@ -994,8 +987,6 @@ void gfs2_glock_xmote_th(struct gfs2_glock *gl, unsigned int state, int flags) gfs2_glock_hold(gl); gl->gl_req_bh = xmote_bh; - atomic_inc(&sdp->sd_lm_lock_calls); - lck_ret = gfs2_lm_lock(sdp, gl->gl_lock, gl->gl_state, state, lck_flags); @@ -1087,8 +1078,6 @@ void gfs2_glock_drop_th(struct gfs2_glock *gl) gfs2_glock_hold(gl); gl->gl_req_bh = drop_bh; - atomic_inc(&sdp->sd_lm_unlock_calls); - ret = gfs2_lm_unlock(sdp, gl->gl_lock, gl->gl_state); if (gfs2_assert_withdraw(sdp, !(ret & LM_OUT_ERROR))) @@ -1313,8 +1302,6 @@ int gfs2_glock_nq(struct gfs2_holder *gh) struct gfs2_sbd *sdp = gl->gl_sbd; int error = 0; - atomic_inc(&sdp->sd_glock_nq_calls); - restart: if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) { set_bit(HIF_ABORTED, &gh->gh_iflags); @@ -1406,8 +1393,6 @@ void gfs2_glock_dq(struct gfs2_holder *gh) struct gfs2_sbd *sdp = gl->gl_sbd; struct gfs2_glock_operations *glops = gl->gl_ops; - atomic_inc(&sdp->sd_glock_dq_calls); - if (gh->gh_flags & GL_SYNC) set_bit(GLF_SYNC, &gl->gl_flags); @@ -1469,8 +1454,6 @@ void gfs2_glock_prefetch(struct gfs2_glock *gl, unsigned int state, int flags) spin_unlock(&gl->gl_spin); glops->go_xmote_th(gl, state, flags); - - atomic_inc(&gl->gl_sbd->sd_glock_prefetch_calls); } /** @@ -1916,8 +1899,6 @@ void gfs2_glock_cb(lm_fsdata_t *fsdata, unsigned int type, void *data) { struct gfs2_sbd *sdp = (struct gfs2_sbd *)fsdata; - atomic_inc(&sdp->sd_lm_callbacks); - switch (type) { case LM_CB_NEED_E: blocking_cb(sdp, (struct lm_lockname *)data, LM_ST_UNLOCKED); diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 7fe422537ff083..0e550e8e5be3a7 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -667,27 +667,7 @@ struct gfs2_sbd { atomic_t sd_glock_count; atomic_t sd_glock_held_count; atomic_t sd_inode_count; - atomic_t sd_bufdata_count; - - atomic_t sd_fh2dentry_misses; atomic_t sd_reclaimed; - atomic_t sd_log_flush_incore; - atomic_t sd_log_flush_ondisk; - - atomic_t sd_glock_nq_calls; - atomic_t sd_glock_dq_calls; - atomic_t sd_glock_prefetch_calls; - atomic_t sd_lm_lock_calls; - atomic_t sd_lm_unlock_calls; - atomic_t sd_lm_callbacks; - - atomic_t sd_ops_address; - atomic_t sd_ops_dentry; - atomic_t sd_ops_export; - atomic_t sd_ops_file; - atomic_t sd_ops_inode; - atomic_t sd_ops_super; - atomic_t sd_ops_vm; char sd_fsname[GFS2_FSNAME_LEN]; char sd_table_name[GFS2_FSNAME_LEN]; diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index e6acb41332e703..2483f0c2c50e37 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -408,8 +408,6 @@ static void log_write_header(struct gfs2_sbd *sdp, uint32_t flags, int pull) unsigned int tail; uint32_t hash; - atomic_inc(&sdp->sd_log_flush_ondisk); - bh = sb_getblk(sdp->sd_vfs, blkno); lock_buffer(bh); memset(bh->b_data, 0, bh->b_size); @@ -488,8 +486,6 @@ void gfs2_log_flush_i(struct gfs2_sbd *sdp, struct gfs2_glock *gl) { struct gfs2_ail *ai; - atomic_inc(&sdp->sd_log_flush_incore); - ai = kzalloc(sizeof(struct gfs2_ail), GFP_NOFS | __GFP_NOFAIL); INIT_LIST_HEAD(&ai->ai_ail1_list); INIT_LIST_HEAD(&ai->ai_ail2_list); diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 8fba8430675506..f4c4dfbf698696 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -146,7 +146,6 @@ static int gfs2_aspace_releasepage(struct page *page, gfp_t gfp_mask) gfs2_assert_warn(sdp, list_empty(&bd->bd_le.le_list)); gfs2_assert_warn(sdp, !bd->bd_ail); kmem_cache_free(gfs2_bufdata_cachep, bd); - atomic_dec(&sdp->sd_bufdata_count); set_v2bd(bh, NULL); } @@ -557,8 +556,6 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh, int meta } bd = kmem_cache_alloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL), - atomic_inc(&gl->gl_sbd->sd_bufdata_count); - memset(bd, 0, sizeof(struct gfs2_bufdata)); bd->bd_bh = bh; diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index c719a2a40698e6..8f839120a473c9 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -166,7 +166,6 @@ static int gfs2_writepage(struct page *page, struct writeback_control *wbc) int error; int done_trans = 0; - atomic_inc(&sdp->sd_ops_address); if (gfs2_assert_withdraw(sdp, gfs2_glock_is_held_excl(ip->i_gl))) { unlock_page(page); return -EIO; @@ -265,8 +264,6 @@ static int gfs2_readpage(struct file *file, struct page *page) struct gfs2_holder gh; int error; - atomic_inc(&sdp->sd_ops_address); - if (file != &gfs2_internal_file_sentinal) { gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh); error = gfs2_glock_nq_m_atime(1, &gh); @@ -319,8 +316,6 @@ static int gfs2_prepare_write(struct file *file, struct page *page, loff_t end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; struct gfs2_alloc *al; - atomic_inc(&sdp->sd_ops_address); - gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME, &ip->i_gh); error = gfs2_glock_nq_m_atime(1, &ip->i_gh); if (error) @@ -412,9 +407,6 @@ static int gfs2_commit_write(struct file *file, struct page *page, struct buffer_head *dibh; struct gfs2_alloc *al = &ip->i_alloc;; - atomic_inc(&sdp->sd_ops_address); - - if (gfs2_assert_withdraw(sdp, gfs2_glock_is_locked_by_me(ip->i_gl))) goto fail_nounlock; @@ -493,8 +485,6 @@ static sector_t gfs2_bmap(struct address_space *mapping, sector_t lblock) sector_t dblock = 0; int error; - atomic_inc(&ip->i_sbd->sd_ops_address); - error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh); if (error) return 0; @@ -615,8 +605,6 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb, struct gfs2_inode *ip = get_v2ip(inode); struct gfs2_sbd *sdp = ip->i_sbd; - atomic_inc(&sdp->sd_ops_address); - if (rw == WRITE) return gfs2_direct_IO_write(iocb, iov, offset, nr_segs); diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c index 5c618611c11b8e..fb8f70d225b91d 100644 --- a/fs/gfs2/ops_dentry.c +++ b/fs/gfs2/ops_dentry.c @@ -45,8 +45,6 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd) lock_kernel(); - atomic_inc(&sdp->sd_ops_dentry); - inode = dentry->d_inode; if (inode && is_bad_inode(inode)) goto invalid; diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index 8389f771d28bb0..611252b7a0d671 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c @@ -32,8 +32,6 @@ static struct dentry *gfs2_decode_fh(struct super_block *sb, { struct gfs2_inum this, parent; - atomic_inc(&get_v2sdp(sb)->sd_ops_export); - if (fh_type != fh_len) return NULL; @@ -66,8 +64,6 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len, struct gfs2_inode *ip = get_v2ip(inode); struct gfs2_sbd *sdp = ip->i_sbd; - atomic_inc(&sdp->sd_ops_export); - if (*len < 4 || (connectable && *len < 8)) return 255; @@ -139,8 +135,6 @@ static int gfs2_get_name(struct dentry *parent, char *name, if (!dir) return -EINVAL; - atomic_inc(&get_v2sdp(dir->i_sb)->sd_ops_export); - if (!S_ISDIR(dir->i_mode) || !inode) return -EINVAL; @@ -173,8 +167,6 @@ static struct dentry *gfs2_get_parent(struct dentry *child) struct dentry *dentry; int error; - atomic_inc(&dip->i_sbd->sd_ops_export); - error = gfs2_lookupi(child->d_inode, &dotdot, 1, &inode); if (error) return ERR_PTR(error); @@ -199,8 +191,6 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_p) struct dentry *dentry; int error; - atomic_inc(&sdp->sd_ops_export); - /* System files? */ inode = gfs2_iget(sb, inum); @@ -256,8 +246,6 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_p) goto fail; } - atomic_inc(&sdp->sd_fh2dentry_misses); - out_ip: error = -EIO; if (ip->i_di.di_flags & GFS2_DIF_SYSTEM) { diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index cf2e26e072455e..0f80e9306016cf 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c @@ -129,8 +129,6 @@ static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin) struct gfs2_holder i_gh; loff_t error; - atomic_inc(&ip->i_sbd->sd_ops_file); - if (origin == 2) { error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh); @@ -278,8 +276,6 @@ static ssize_t gfs2_read(struct file *filp, char __user *buf, size_t size, struct kiocb kiocb; ssize_t ret; - atomic_inc(&get_v2sdp(filp->f_mapping->host->i_sb)->sd_ops_file); - init_sync_kiocb(&kiocb, filp); ret = __gfs2_file_aio_read(&kiocb, &local_iov, 1, offset); if (-EIOCBQUEUED == ret) @@ -293,8 +289,6 @@ static ssize_t gfs2_file_readv(struct file *filp, const struct iovec *iov, struct kiocb kiocb; ssize_t ret; - atomic_inc(&get_v2sdp(filp->f_mapping->host->i_sb)->sd_ops_file); - init_sync_kiocb(&kiocb, filp); ret = __gfs2_file_aio_read(&kiocb, iov, nr_segs, ppos); if (-EIOCBQUEUED == ret) @@ -308,8 +302,6 @@ static ssize_t gfs2_file_aio_read(struct kiocb *iocb, char __user *buf, struct file *filp = iocb->ki_filp; struct iovec local_iov = { .iov_base = buf, .iov_len = count }; - atomic_inc(&get_v2sdp(filp->f_mapping->host->i_sb)->sd_ops_file); - BUG_ON(iocb->ki_pos != pos); return __gfs2_file_aio_read(iocb, &local_iov, 1, &iocb->ki_pos); } @@ -529,8 +521,6 @@ static int gfs2_readdir(struct file *file, void *dirent, filldir_t filldir) { int error; - atomic_inc(&get_v2sdp(file->f_mapping->host->i_sb)->sd_ops_file); - if (strcmp(current->comm, "nfsd") != 0) error = readdir_reg(file, dirent, filldir); else @@ -539,7 +529,8 @@ static int gfs2_readdir(struct file *file, void *dirent, filldir_t filldir) return error; } -static int gfs2_ioctl_flags(struct gfs2_inode *ip, unsigned int cmd, unsigned long arg) +static int gfs2_ioctl_flags(struct gfs2_inode *ip, unsigned int cmd, + unsigned long arg) { unsigned int lmode = (cmd == GFS2_IOCTL_SETFLAGS) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; struct buffer_head *dibh; @@ -618,8 +609,6 @@ static int gfs2_ioctl(struct inode *inode, struct file *file, unsigned int cmd, { struct gfs2_inode *ip = get_v2ip(inode); - atomic_inc(&ip->i_sbd->sd_ops_file); - switch (cmd) { case GFS2_IOCTL_SETFLAGS: case GFS2_IOCTL_GETFLAGS: @@ -644,8 +633,6 @@ static int gfs2_mmap(struct file *file, struct vm_area_struct *vma) struct gfs2_holder i_gh; int error; - atomic_inc(&ip->i_sbd->sd_ops_file); - gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &i_gh); error = gfs2_glock_nq_atime(&i_gh); if (error) { @@ -682,8 +669,6 @@ static int gfs2_open(struct inode *inode, struct file *file) struct gfs2_file *fp; int error; - atomic_inc(&ip->i_sbd->sd_ops_file); - fp = kzalloc(sizeof(struct gfs2_file), GFP_KERNEL); if (!fp) return -ENOMEM; @@ -741,8 +726,6 @@ static int gfs2_close(struct inode *inode, struct file *file) struct gfs2_sbd *sdp = get_v2sdp(inode->i_sb); struct gfs2_file *fp; - atomic_inc(&sdp->sd_ops_file); - fp = get_v2fp(file); set_v2fp(file, NULL); @@ -766,7 +749,6 @@ static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync) { struct gfs2_inode *ip = get_v2ip(dentry->d_inode); - atomic_inc(&ip->i_sbd->sd_ops_file); gfs2_log_flush_glock(ip->i_gl); return 0; @@ -789,8 +771,6 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) { .ln_number = ip->i_num.no_addr, .ln_type = LM_TYPE_PLOCK }; - atomic_inc(&sdp->sd_ops_file); - if (!(fl->fl_flags & FL_POSIX)) return -ENOLCK; if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID) @@ -839,9 +819,6 @@ static ssize_t gfs2_sendfile(struct file *in_file, loff_t *offset, size_t count, read_actor_t actor, void *target) { struct gfs2_inode *ip = get_v2ip(in_file->f_mapping->host); - - atomic_inc(&ip->i_sbd->sd_ops_file); - return generic_file_sendfile(in_file, offset, count, actor, target); } @@ -921,8 +898,6 @@ static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl) struct gfs2_inode *ip = get_v2ip(file->f_mapping->host); struct gfs2_sbd *sdp = ip->i_sbd; - atomic_inc(&ip->i_sbd->sd_ops_file); - if (!(fl->fl_flags & FL_FLOCK)) return -ENOLCK; if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID) diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 9fb9490eb67afe..9971a30eb78ec3 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -56,8 +56,6 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry, int new = 1; int error; - atomic_inc(&sdp->sd_ops_inode); - gfs2_holder_init(dip->i_gl, 0, 0, ghs); for (;;) { @@ -113,8 +111,6 @@ static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry, struct inode *inode = NULL; int error; - atomic_inc(&sdp->sd_ops_inode); - if (!sdp->sd_args.ar_localcaching) dentry->d_op = &gfs2_dops; @@ -152,8 +148,6 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, int alloc_required; int error; - atomic_inc(&sdp->sd_ops_inode); - if (S_ISDIR(ip->i_di.di_mode)) return -EPERM; @@ -287,8 +281,6 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry) struct gfs2_holder ghs[2]; int error; - atomic_inc(&sdp->sd_ops_inode); - error = gfs2_unlinked_get(sdp, &ul); if (error) return error; @@ -345,8 +337,6 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry, int size; int error; - atomic_inc(&sdp->sd_ops_inode); - /* Must be stuffed with a null terminator for gfs2_follow_link() */ size = strlen(symname); if (size > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode) - 1) @@ -405,8 +395,6 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode) struct buffer_head *dibh; int error; - atomic_inc(&sdp->sd_ops_inode); - gfs2_holder_init(dip->i_gl, 0, 0, ghs); inode = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode); @@ -487,8 +475,6 @@ static int gfs2_rmdir(struct inode *dir, struct dentry *dentry) struct gfs2_holder ghs[2]; int error; - atomic_inc(&sdp->sd_ops_inode); - error = gfs2_unlinked_get(sdp, &ul); if (error) return error; @@ -556,8 +542,6 @@ static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, uint32_t major = 0, minor = 0; int error; - atomic_inc(&sdp->sd_ops_inode); - switch (mode & S_IFMT) { case S_IFBLK: case S_IFCHR: @@ -631,8 +615,6 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, unsigned int x; int error; - atomic_inc(&sdp->sd_ops_inode); - if (ndentry->d_inode) { nip = get_v2ip(ndentry->d_inode); if (ip == nip) @@ -871,8 +853,6 @@ static int gfs2_readlink(struct dentry *dentry, char __user *user_buf, unsigned int len = GFS2_FAST_NAME_SIZE; int error; - atomic_inc(&ip->i_sbd->sd_ops_inode); - error = gfs2_readlinki(ip, &buf, &len); if (error) return error; @@ -909,8 +889,6 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd) unsigned int len = GFS2_FAST_NAME_SIZE; int error; - atomic_inc(&ip->i_sbd->sd_ops_inode); - error = gfs2_readlinki(ip, &buf, &len); if (!error) { error = vfs_follow_link(nd, buf); @@ -936,8 +914,6 @@ static int gfs2_permission(struct inode *inode, int mask, struct nameidata *nd) struct gfs2_holder i_gh; int error; - atomic_inc(&ip->i_sbd->sd_ops_inode); - if (ip->i_vn == ip->i_gl->gl_vn) return generic_permission(inode, mask, gfs2_check_acl); @@ -1053,8 +1029,6 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr) struct gfs2_holder i_gh; int error; - atomic_inc(&ip->i_sbd->sd_ops_inode); - error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh); if (error) return error; @@ -1102,8 +1076,6 @@ static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, struct gfs2_holder gh; int error; - atomic_inc(&ip->i_sbd->sd_ops_inode); - error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); if (!error) { generic_fillattr(inode, stat); @@ -1119,8 +1091,6 @@ static int gfs2_setxattr(struct dentry *dentry, const char *name, struct gfs2_inode *ip = get_v2ip(dentry->d_inode); struct gfs2_ea_request er; - atomic_inc(&ip->i_sbd->sd_ops_inode); - memset(&er, 0, sizeof(struct gfs2_ea_request)); er.er_type = gfs2_ea_name2type(name, &er.er_name); if (er.er_type == GFS2_EATYPE_UNUSED) @@ -1140,8 +1110,6 @@ static ssize_t gfs2_getxattr(struct dentry *dentry, const char *name, { struct gfs2_ea_request er; - atomic_inc(&get_v2sdp(dentry->d_inode->i_sb)->sd_ops_inode); - memset(&er, 0, sizeof(struct gfs2_ea_request)); er.er_type = gfs2_ea_name2type(name, &er.er_name); if (er.er_type == GFS2_EATYPE_UNUSED) @@ -1157,8 +1125,6 @@ static ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size) { struct gfs2_ea_request er; - atomic_inc(&get_v2sdp(dentry->d_inode->i_sb)->sd_ops_inode); - memset(&er, 0, sizeof(struct gfs2_ea_request)); er.er_data = (size) ? buffer : NULL; er.er_data_len = size; @@ -1170,8 +1136,6 @@ static int gfs2_removexattr(struct dentry *dentry, const char *name) { struct gfs2_ea_request er; - atomic_inc(&get_v2sdp(dentry->d_inode->i_sb)->sd_ops_inode); - memset(&er, 0, sizeof(struct gfs2_ea_request)); er.er_type = gfs2_ea_name2type(name, &er.er_name); if (er.er_type == GFS2_EATYPE_UNUSED) diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 9130d0d0df3ce2..cd45ec93a04376 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -46,8 +46,6 @@ static int gfs2_write_inode(struct inode *inode, int sync) { struct gfs2_inode *ip = get_v2ip(inode); - atomic_inc(&ip->i_sbd->sd_ops_super); - if (current->flags & PF_MEMALLOC) return 0; if (ip && sync) @@ -70,8 +68,6 @@ static void gfs2_put_super(struct super_block *sb) if (!sdp) return; - atomic_inc(&sdp->sd_ops_super); - /* Unfreeze the filesystem, if we need to */ mutex_lock(&sdp->sd_freeze_lock); @@ -156,7 +152,6 @@ static void gfs2_put_super(struct super_block *sb) static void gfs2_write_super(struct super_block *sb) { struct gfs2_sbd *sdp = get_v2sdp(sb); - atomic_inc(&sdp->sd_ops_super); gfs2_log_flush(sdp); } @@ -171,8 +166,6 @@ static void gfs2_write_super_lockfs(struct super_block *sb) struct gfs2_sbd *sdp = get_v2sdp(sb); int error; - atomic_inc(&sdp->sd_ops_super); - for (;;) { error = gfs2_freeze_fs(sdp); if (!error) @@ -202,8 +195,6 @@ static void gfs2_write_super_lockfs(struct super_block *sb) static void gfs2_unlockfs(struct super_block *sb) { struct gfs2_sbd *sdp = get_v2sdp(sb); - - atomic_inc(&sdp->sd_ops_super); gfs2_unfreeze_fs(sdp); } @@ -221,8 +212,6 @@ static int gfs2_statfs(struct super_block *sb, struct kstatfs *buf) struct gfs2_statfs_change sc; int error; - atomic_inc(&sdp->sd_ops_super); - if (gfs2_tune_get(sdp, gt_statfs_slow)) error = gfs2_statfs_slow(sdp, &sc); else @@ -259,8 +248,6 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data) struct gfs2_sbd *sdp = get_v2sdp(sb); int error; - atomic_inc(&sdp->sd_ops_super); - error = gfs2_mount_args(sdp, data, 1); if (error) return error; @@ -298,8 +285,6 @@ static void gfs2_clear_inode(struct inode *inode) { struct gfs2_inode *ip = get_v2ip(inode); - atomic_inc(&get_v2sdp(inode->i_sb)->sd_ops_super); - if (ip) { spin_lock(&ip->i_spin); ip->i_vnode = NULL; @@ -324,8 +309,6 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) struct gfs2_sbd *sdp = get_v2sdp(mnt->mnt_sb); struct gfs2_args *args = &sdp->sd_args; - atomic_inc(&sdp->sd_ops_super); - if (args->ar_lockproto[0]) seq_printf(s, ",lockproto=%s", args->ar_lockproto); if (args->ar_locktable[0]) diff --git a/fs/gfs2/ops_vm.c b/fs/gfs2/ops_vm.c index 8f77bb7896bd6e..808110e3ec5e4e 100644 --- a/fs/gfs2/ops_vm.c +++ b/fs/gfs2/ops_vm.c @@ -48,8 +48,6 @@ static struct page *gfs2_private_nopage(struct vm_area_struct *area, struct page *result; int error; - atomic_inc(&ip->i_sbd->sd_ops_vm); - error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh); if (error) return NULL; @@ -149,8 +147,6 @@ static struct page *gfs2_sharewrite_nopage(struct vm_area_struct *area, int alloc_required; int error; - atomic_inc(&ip->i_sbd->sd_ops_vm); - error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh); if (error) return NULL; diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index c5984351e4d8da..f87df8ec041ea1 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c @@ -319,85 +319,23 @@ struct counters_attr { ssize_t (*show)(struct gfs2_sbd *, char *); }; -#define COUNTERS_ATTR_GENERAL(name, fmt, val) \ +#define COUNTERS_ATTR(name, fmt) \ static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \ { \ - return sprintf(buf, fmt, val); \ + return sprintf(buf, fmt, (unsigned int)atomic_read(&sdp->sd_##name)); \ } \ static struct counters_attr counters_attr_##name = __ATTR_RO(name) -#define COUNTERS_ATTR_SIMPLE(name, fmt) \ - COUNTERS_ATTR_GENERAL(name, fmt, sdp->sd_##name) - -#define COUNTERS_ATTR_ATOMIC(name, fmt) \ - COUNTERS_ATTR_GENERAL(name, fmt, (unsigned int)atomic_read(&sdp->sd_##name)) - -COUNTERS_ATTR_ATOMIC(glock_count, "%u\n"); -COUNTERS_ATTR_ATOMIC(glock_held_count, "%u\n"); -COUNTERS_ATTR_ATOMIC(inode_count, "%u\n"); -COUNTERS_ATTR_ATOMIC(bufdata_count, "%u\n"); -COUNTERS_ATTR_ATOMIC(unlinked_count, "%u\n"); -COUNTERS_ATTR_ATOMIC(quota_count, "%u\n"); -COUNTERS_ATTR_SIMPLE(log_num_gl, "%u\n"); -COUNTERS_ATTR_SIMPLE(log_num_buf, "%u\n"); -COUNTERS_ATTR_SIMPLE(log_num_revoke, "%u\n"); -COUNTERS_ATTR_SIMPLE(log_num_rg, "%u\n"); -COUNTERS_ATTR_SIMPLE(log_num_databuf, "%u\n"); -COUNTERS_ATTR_SIMPLE(log_blks_free, "%u\n"); -COUNTERS_ATTR_GENERAL(jd_blocks, "%u\n", sdp->sd_jdesc->jd_blocks); -COUNTERS_ATTR_ATOMIC(reclaim_count, "%u\n"); -COUNTERS_ATTR_SIMPLE(log_wraps, "%llu\n"); -COUNTERS_ATTR_ATOMIC(fh2dentry_misses, "%u\n"); -COUNTERS_ATTR_ATOMIC(reclaimed, "%u\n"); -COUNTERS_ATTR_ATOMIC(log_flush_incore, "%u\n"); -COUNTERS_ATTR_ATOMIC(log_flush_ondisk, "%u\n"); -COUNTERS_ATTR_ATOMIC(glock_nq_calls, "%u\n"); -COUNTERS_ATTR_ATOMIC(glock_dq_calls, "%u\n"); -COUNTERS_ATTR_ATOMIC(glock_prefetch_calls, "%u\n"); -COUNTERS_ATTR_ATOMIC(lm_lock_calls, "%u\n"); -COUNTERS_ATTR_ATOMIC(lm_unlock_calls, "%u\n"); -COUNTERS_ATTR_ATOMIC(lm_callbacks, "%u\n"); -COUNTERS_ATTR_ATOMIC(ops_address, "%u\n"); -COUNTERS_ATTR_ATOMIC(ops_dentry, "%u\n"); -COUNTERS_ATTR_ATOMIC(ops_export, "%u\n"); -COUNTERS_ATTR_ATOMIC(ops_file, "%u\n"); -COUNTERS_ATTR_ATOMIC(ops_inode, "%u\n"); -COUNTERS_ATTR_ATOMIC(ops_super, "%u\n"); -COUNTERS_ATTR_ATOMIC(ops_vm, "%u\n"); +COUNTERS_ATTR(glock_count, "%u\n"); +COUNTERS_ATTR(glock_held_count, "%u\n"); +COUNTERS_ATTR(inode_count, "%u\n"); +COUNTERS_ATTR(reclaimed, "%u\n"); static struct attribute *counters_attrs[] = { &counters_attr_glock_count.attr, &counters_attr_glock_held_count.attr, &counters_attr_inode_count.attr, - &counters_attr_bufdata_count.attr, - &counters_attr_unlinked_count.attr, - &counters_attr_quota_count.attr, - &counters_attr_log_num_gl.attr, - &counters_attr_log_num_buf.attr, - &counters_attr_log_num_revoke.attr, - &counters_attr_log_num_rg.attr, - &counters_attr_log_num_databuf.attr, - &counters_attr_log_blks_free.attr, - &counters_attr_jd_blocks.attr, - &counters_attr_reclaim_count.attr, - &counters_attr_log_wraps.attr, - &counters_attr_fh2dentry_misses.attr, &counters_attr_reclaimed.attr, - &counters_attr_log_flush_incore.attr, - &counters_attr_log_flush_ondisk.attr, - &counters_attr_glock_nq_calls.attr, - &counters_attr_glock_dq_calls.attr, - &counters_attr_glock_prefetch_calls.attr, - &counters_attr_lm_lock_calls.attr, - &counters_attr_lm_unlock_calls.attr, - &counters_attr_lm_callbacks.attr, - &counters_attr_ops_address.attr, - &counters_attr_ops_dentry.attr, - &counters_attr_ops_export.attr, - &counters_attr_ops_file.attr, - &counters_attr_ops_inode.attr, - &counters_attr_ops_super.attr, - &counters_attr_ops_vm.attr, NULL }; -- cgit 1.2.3-korg From d95cb943f5b217c5b5f97f5af0fea3c511ed9c97 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 23 Feb 2006 10:13:13 +0000 Subject: [GFS2] Patch to remove stats counters from GFS2 (II) Signed-off-by: David Teigland Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 2 -- fs/gfs2/ops_dentry.c | 1 - fs/gfs2/ops_export.c | 1 - fs/gfs2/ops_file.c | 2 -- 4 files changed, 6 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index cf1dc17faf4f4d..d4fa395ed39f2f 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -825,7 +825,6 @@ static void handle_callback(struct gfs2_glock *gl, unsigned int state) static void state_change(struct gfs2_glock *gl, unsigned int new_state) { - struct gfs2_sbd *sdp = gl->gl_sbd; int held1, held2; held1 = (gl->gl_state != LM_ST_UNLOCKED); @@ -1390,7 +1389,6 @@ int gfs2_glock_wait(struct gfs2_holder *gh) void gfs2_glock_dq(struct gfs2_holder *gh) { struct gfs2_glock *gl = gh->gh_gl; - struct gfs2_sbd *sdp = gl->gl_sbd; struct gfs2_glock_operations *glops = gl->gl_ops; if (gh->gh_flags & GL_SYNC) diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c index fb8f70d225b91d..b020ad8f180b95 100644 --- a/fs/gfs2/ops_dentry.c +++ b/fs/gfs2/ops_dentry.c @@ -35,7 +35,6 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd) { struct dentry *parent = dget_parent(dentry); struct gfs2_inode *dip = get_v2ip(parent->d_inode); - struct gfs2_sbd *sdp = dip->i_sbd; struct inode *inode; struct gfs2_holder d_gh; struct gfs2_inode *ip; diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index 611252b7a0d671..60d006402553f9 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c @@ -161,7 +161,6 @@ static int gfs2_get_name(struct dentry *parent, char *name, static struct dentry *gfs2_get_parent(struct dentry *child) { - struct gfs2_inode *dip = get_v2ip(child->d_inode); struct qstr dotdot = { .name = "..", .len = 2 }; struct inode *inode; struct dentry *dentry; diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index 0f80e9306016cf..989f0f70fc2ec4 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c @@ -299,7 +299,6 @@ static ssize_t gfs2_file_readv(struct file *filp, const struct iovec *iov, static ssize_t gfs2_file_aio_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t pos) { - struct file *filp = iocb->ki_filp; struct iovec local_iov = { .iov_base = buf, .iov_len = count }; BUG_ON(iocb->ki_pos != pos); @@ -818,7 +817,6 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) static ssize_t gfs2_sendfile(struct file *in_file, loff_t *offset, size_t count, read_actor_t actor, void *target) { - struct gfs2_inode *ip = get_v2ip(in_file->f_mapping->host); return generic_file_sendfile(in_file, offset, count, actor, target); } -- cgit 1.2.3-korg From d92a8d48085df863032110d9ccb221cde98d14e1 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Mon, 27 Feb 2006 10:57:14 -0500 Subject: [GFS2] Audit printk and kmalloc All printk calls now have KERN_ set where required and a couple of kmalloc(), memset(.., 0, ...) calls changed to kzalloc(). This is in response to comments from: Pekka Enberg and Eric Sesterhenn Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 52 +++++++++++++++++++++---------------------- fs/gfs2/locking.c | 9 ++++---- fs/gfs2/locking/dlm/lock.c | 7 +++--- fs/gfs2/locking/dlm/main.c | 4 ++-- fs/gfs2/locking/dlm/plock.c | 13 ++++++----- fs/gfs2/locking/nolock/main.c | 13 +++++------ fs/gfs2/ondisk.c | 10 ++++----- fs/gfs2/ops_fstype.c | 4 ++-- fs/gfs2/ops_super.c | 2 +- fs/gfs2/super.c | 16 ++++++------- 10 files changed, 64 insertions(+), 66 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index d4fa395ed39f2f..f30fde91d14af5 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -2315,17 +2315,17 @@ static int dump_holder(char *str, struct gfs2_holder *gh) unsigned int x; int error = -ENOBUFS; - printk(" %s\n", str); - printk(" owner = %ld\n", + printk(KERN_INFO " %s\n", str); + printk(KERN_INFO " owner = %ld\n", (gh->gh_owner) ? (long)gh->gh_owner->pid : -1); - printk(" gh_state = %u\n", gh->gh_state); - printk(" gh_flags ="); + printk(KERN_INFO " gh_state = %u\n", gh->gh_state); + printk(KERN_INFO " gh_flags ="); for (x = 0; x < 32; x++) if (gh->gh_flags & (1 << x)) printk(" %u", x); printk(" \n"); - printk(" error = %d\n", gh->gh_error); - printk(" gh_iflags ="); + printk(KERN_INFO " error = %d\n", gh->gh_error); + printk(KERN_INFO " gh_iflags ="); for (x = 0; x < 32; x++) if (test_bit(x, &gh->gh_iflags)) printk(" %u", x); @@ -2348,17 +2348,17 @@ static int dump_inode(struct gfs2_inode *ip) unsigned int x; int error = -ENOBUFS; - printk(" Inode:\n"); - printk(" num = %llu %llu\n", + printk(KERN_INFO " Inode:\n"); + printk(KERN_INFO " num = %llu %llu\n", ip->i_num.no_formal_ino, ip->i_num.no_addr); - printk(" type = %u\n", IF2DT(ip->i_di.di_mode)); - printk(" i_count = %d\n", atomic_read(&ip->i_count)); - printk(" i_flags ="); + printk(KERN_INFO " type = %u\n", IF2DT(ip->i_di.di_mode)); + printk(KERN_INFO " i_count = %d\n", atomic_read(&ip->i_count)); + printk(KERN_INFO " i_flags ="); for (x = 0; x < 32; x++) if (test_bit(x, &ip->i_flags)) printk(" %u", x); printk(" \n"); - printk(" vnode = %s\n", (ip->i_vnode) ? "yes" : "no"); + printk(KERN_INFO " vnode = %s\n", (ip->i_vnode) ? "yes" : "no"); error = 0; @@ -2381,30 +2381,30 @@ static int dump_glock(struct gfs2_glock *gl) spin_lock(&gl->gl_spin); - printk("Glock (%u, %llu)\n", + printk(KERN_INFO "Glock (%u, %llu)\n", gl->gl_name.ln_type, gl->gl_name.ln_number); - printk(" gl_flags ="); + printk(KERN_INFO " gl_flags ="); for (x = 0; x < 32; x++) if (test_bit(x, &gl->gl_flags)) printk(" %u", x); printk(" \n"); - printk(" gl_ref = %d\n", atomic_read(&gl->gl_ref.refcount)); - printk(" gl_state = %u\n", gl->gl_state); - printk(" req_gh = %s\n", (gl->gl_req_gh) ? "yes" : "no"); - printk(" req_bh = %s\n", (gl->gl_req_bh) ? "yes" : "no"); - printk(" lvb_count = %d\n", atomic_read(&gl->gl_lvb_count)); - printk(" object = %s\n", (gl->gl_object) ? "yes" : "no"); - printk(" le = %s\n", + printk(KERN_INFO " gl_ref = %d\n", atomic_read(&gl->gl_ref.refcount)); + printk(KERN_INFO " gl_state = %u\n", gl->gl_state); + printk(KERN_INFO " req_gh = %s\n", (gl->gl_req_gh) ? "yes" : "no"); + printk(KERN_INFO " req_bh = %s\n", (gl->gl_req_bh) ? "yes" : "no"); + printk(KERN_INFO " lvb_count = %d\n", atomic_read(&gl->gl_lvb_count)); + printk(KERN_INFO " object = %s\n", (gl->gl_object) ? "yes" : "no"); + printk(KERN_INFO " le = %s\n", (list_empty(&gl->gl_le.le_list)) ? "no" : "yes"); - printk(" reclaim = %s\n", + printk(KERN_INFO " reclaim = %s\n", (list_empty(&gl->gl_reclaim)) ? "no" : "yes"); if (gl->gl_aspace) - printk(" aspace = %lu\n", + printk(KERN_INFO " aspace = %lu\n", gl->gl_aspace->i_mapping->nrpages); else - printk(" aspace = no\n"); - printk(" ail = %d\n", atomic_read(&gl->gl_ail_count)); + printk(KERN_INFO " aspace = no\n"); + printk(KERN_INFO " ail = %d\n", atomic_read(&gl->gl_ail_count)); if (gl->gl_req_gh) { error = dump_holder("Request", gl->gl_req_gh); if (error) @@ -2438,7 +2438,7 @@ static int dump_glock(struct gfs2_glock *gl) goto out; } else { error = -ENOBUFS; - printk(" Inode: busy\n"); + printk(KERN_INFO " Inode: busy\n"); } } diff --git a/fs/gfs2/locking.c b/fs/gfs2/locking.c index 2d2f8fe53999db..0f4c50ebcbade6 100644 --- a/fs/gfs2/locking.c +++ b/fs/gfs2/locking.c @@ -46,18 +46,17 @@ int gfs_register_lockproto(struct lm_lockops *proto) list_for_each_entry(lw, &lmh_list, lw_list) { if (!strcmp(lw->lw_ops->lm_proto_name, proto->lm_proto_name)) { up(&lmh_lock); - printk("GFS2: protocol %s already exists\n", + printk(KERN_INFO "GFS2: protocol %s already exists\n", proto->lm_proto_name); return -EEXIST; } } - lw = kmalloc(sizeof(struct lmh_wrapper), GFP_KERNEL); + lw = kzalloc(sizeof(struct lmh_wrapper), GFP_KERNEL); if (!lw) { up(&lmh_lock); return -ENOMEM; } - memset(lw, 0, sizeof(struct lmh_wrapper)); lw->lw_ops = proto; list_add(&lw->lw_list, &lmh_list); @@ -90,7 +89,7 @@ void gfs_unregister_lockproto(struct lm_lockops *proto) up(&lmh_lock); - printk("GFS2: can't unregister lock protocol %s\n", + printk(KERN_WARNING "GFS2: can't unregister lock protocol %s\n", proto->lm_proto_name); } @@ -136,7 +135,7 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data, request_module(proto_name); goto retry; } - printk("GFS2: can't find protocol %s\n", proto_name); + printk(KERN_INFO "GFS2: can't find protocol %s\n", proto_name); error = -ENOENT; goto out; } diff --git a/fs/gfs2/locking/dlm/lock.c b/fs/gfs2/locking/dlm/lock.c index 666d696dc8ce7c..1799d2237e7e35 100644 --- a/fs/gfs2/locking/dlm/lock.c +++ b/fs/gfs2/locking/dlm/lock.c @@ -34,7 +34,7 @@ static inline void gdlm_bast(void *astarg, int mode) struct gdlm_ls *ls = lp->ls; if (!mode) { - printk("lock_dlm: bast mode zero %x,%llx\n", + printk(KERN_INFO "lock_dlm: bast mode zero %x,%llx\n", lp->lockname.ln_type, lp->lockname.ln_number); return; } @@ -408,7 +408,7 @@ static int hold_null_lock(struct gdlm_lock *lp) int error; if (lp->hold_null) { - printk("lock_dlm: lvb already held\n"); + printk(KERN_INFO "lock_dlm: lvb already held\n"); return 0; } @@ -429,7 +429,8 @@ static int hold_null_lock(struct gdlm_lock *lp) wait_for_completion(&lpn->ast_wait); error = lp->lksb.sb_status; if (error) { - printk("lock_dlm: hold_null_lock dlm error %d\n", error); + printk(KERN_INFO "lock_dlm: hold_null_lock dlm error %d\n", + error); gdlm_delete_lp(lpn); lpn = NULL; } diff --git a/fs/gfs2/locking/dlm/main.c b/fs/gfs2/locking/dlm/main.c index 2c13c916a35209..1c0943de940812 100644 --- a/fs/gfs2/locking/dlm/main.c +++ b/fs/gfs2/locking/dlm/main.c @@ -22,7 +22,7 @@ int __init init_lock_dlm(void) error = gfs_register_lockproto(&gdlm_ops); if (error) { - printk("lock_dlm: can't register protocol: %d\n", error); + printk(KERN_WARNING "lock_dlm: can't register protocol: %d\n", error); return error; } @@ -42,7 +42,7 @@ int __init init_lock_dlm(void) gdlm_drop_count = GDLM_DROP_COUNT; gdlm_drop_period = GDLM_DROP_PERIOD; - printk("Lock_DLM (built %s %s) installed\n", __DATE__, __TIME__); + printk(KERN_INFO "Lock_DLM (built %s %s) installed\n", __DATE__, __TIME__); return 0; } diff --git a/fs/gfs2/locking/dlm/plock.c b/fs/gfs2/locking/dlm/plock.c index 382847205bc18e..f7ac5821def9d5 100644 --- a/fs/gfs2/locking/dlm/plock.c +++ b/fs/gfs2/locking/dlm/plock.c @@ -83,7 +83,7 @@ int gdlm_plock(lm_lockspace_t *lockspace, struct lm_lockname *name, spin_lock(&ops_lock); if (!list_empty(&op->list)) { - printk("plock op on list\n"); + printk(KERN_INFO "plock op on list\n"); list_del(&op->list); } spin_unlock(&ops_lock); @@ -127,7 +127,7 @@ int gdlm_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name, spin_lock(&ops_lock); if (!list_empty(&op->list)) { - printk("punlock op on list\n"); + printk(KERN_INFO "punlock op on list\n"); list_del(&op->list); } spin_unlock(&ops_lock); @@ -162,7 +162,7 @@ int gdlm_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name, spin_lock(&ops_lock); if (!list_empty(&op->list)) { - printk("plock_get op on list\n"); + printk(KERN_INFO "plock_get op on list\n"); list_del(&op->list); } spin_unlock(&ops_lock); @@ -242,7 +242,7 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count, if (found) wake_up(&recv_wq); else - printk("gdlm dev_write no op %x %llx\n", info.fsid, + printk(KERN_INFO "gdlm dev_write no op %x %llx\n", info.fsid, info.number); return count; } @@ -285,13 +285,14 @@ int gdlm_plock_init(void) rv = misc_register(&plock_dev_misc); if (rv) - printk("gdlm_plock_init: misc_register failed %d", rv); + printk(KERN_INFO "gdlm_plock_init: misc_register failed %d", + rv); return rv; } void gdlm_plock_exit(void) { if (misc_deregister(&plock_dev_misc) < 0) - printk("gdlm_plock_exit: misc_deregister failed"); + printk(KERN_INFO "gdlm_plock_exit: misc_deregister failed"); } diff --git a/fs/gfs2/locking/nolock/main.c b/fs/gfs2/locking/nolock/main.c index b716e336c0732f..7ede0906b2c65d 100644 --- a/fs/gfs2/locking/nolock/main.c +++ b/fs/gfs2/locking/nolock/main.c @@ -44,11 +44,10 @@ static int nolock_mount(char *table_name, char *host_data, sscanf(c, "%u", &jid); } - nl = kmalloc(sizeof(struct nolock_lockspace), GFP_KERNEL); + nl = kzalloc(sizeof(struct nolock_lockspace), GFP_KERNEL); if (!nl) return -ENOMEM; - memset(nl, 0, sizeof(struct nolock_lockspace)); nl->nl_lvb_size = min_lvb_size; lockstruct->ls_jid = jid; @@ -147,10 +146,8 @@ static int nolock_hold_lvb(lm_lock_t *lock, char **lvbp) struct nolock_lockspace *nl = (struct nolock_lockspace *)lock; int error = 0; - *lvbp = kmalloc(nl->nl_lvb_size, GFP_KERNEL); - if (*lvbp) - memset(*lvbp, 0, nl->nl_lvb_size); - else + *lvbp = kzalloc(nl->nl_lvb_size, GFP_KERNEL); + if (!*lvbp) error = -ENOMEM; return error; @@ -246,11 +243,11 @@ int __init init_nolock(void) error = gfs_register_lockproto(&nolock_ops); if (error) { - printk("lock_nolock: can't register protocol: %d\n", error); + printk(KERN_WARNING "lock_nolock: can't register protocol: %d\n", error); return error; } - printk("Lock_Nolock (built %s %s) installed\n", __DATE__, __TIME__); + printk(KERN_INFO "Lock_Nolock (built %s %s) installed\n", __DATE__, __TIME__); return 0; } diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c index 854b5049b8d5bc..964abd2760ffb8 100644 --- a/fs/gfs2/ondisk.c +++ b/fs/gfs2/ondisk.c @@ -17,7 +17,7 @@ #include "gfs2.h" #include -#define pv(struct, member, fmt) printk(" "#member" = "fmt"\n", struct->member); +#define pv(struct, member, fmt) printk(KERN_INFO " "#member" = "fmt"\n", struct->member); #define pa(struct, member, count) print_array(#member, struct->member, count); /** @@ -32,11 +32,11 @@ static void print_array(char *title, char *buf, int count) { int x; - printk(" %s =\n", title); + printk(KERN_INFO " %s =\n" KERN_INFO, title); for (x = 0; x < count; x++) { printk("%.2X ", (unsigned char)buf[x]); if (x % 16 == 15) - printk("\n"); + printk("\n" KERN_INFO); } if (x % 16) printk("\n"); @@ -338,7 +338,7 @@ void gfs2_dirent_print(struct gfs2_dirent *de, char *name) memset(buf, 0, GFS2_FNAMESIZE + 1); memcpy(buf, name, de->de_name_len); - printk(" name = %s\n", buf); + printk(KERN_INFO " name = %s\n", buf); } void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf) @@ -401,7 +401,7 @@ void gfs2_ea_header_print(struct gfs2_ea_header *ea, char *name) memset(buf, 0, GFS2_EA_MAX_NAME_LEN + 1); memcpy(buf, name, ea->ea_name_len); - printk(" name = %s\n", buf); + printk(KERN_INFO " name = %s\n", buf); } void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf) diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 751178ab497c8a..a85f1a2676f663 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -772,13 +772,13 @@ static int fill_super(struct super_block *sb, void *data, int silent) sdp = init_sbd(sb); if (!sdp) { - printk("GFS2: can't alloc struct gfs2_sbd\n"); + printk(KERN_WARNING "GFS2: can't alloc struct gfs2_sbd\n"); return -ENOMEM; } error = gfs2_mount_args(sdp, (char *)data, 0); if (error) { - printk("GFS2: can't parse mount arguments\n"); + printk(KERN_WARNING "GFS2: can't parse mount arguments\n"); goto fail; } diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index cd45ec93a04376..48a94522406ea5 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index be80771c414d25..60e266618729e8 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -94,7 +94,7 @@ int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent) if (sb->sb_header.mh_magic != GFS2_MAGIC || sb->sb_header.mh_type != GFS2_METATYPE_SB) { if (!silent) - printk("GFS2: not a GFS2 filesystem\n"); + printk(KERN_WARNING "GFS2: not a GFS2 filesystem\n"); return -EINVAL; } @@ -110,11 +110,11 @@ int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent) break; if (!gfs2_old_fs_formats[x]) { - printk("GFS2: code version (%u, %u) is incompatible " + printk(KERN_WARNING "GFS2: code version (%u, %u) is incompatible " "with ondisk format (%u, %u)\n", GFS2_FORMAT_FS, GFS2_FORMAT_MULTI, sb->sb_fs_format, sb->sb_multihost_format); - printk("GFS2: I don't know how to upgrade this FS\n"); + printk(KERN_WARNING "GFS2: I don't know how to upgrade this FS\n"); return -EINVAL; } } @@ -125,23 +125,23 @@ int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent) break; if (!gfs2_old_multihost_formats[x]) { - printk("GFS2: code version (%u, %u) is incompatible " + printk(KERN_WARNING "GFS2: code version (%u, %u) is incompatible " "with ondisk format (%u, %u)\n", GFS2_FORMAT_FS, GFS2_FORMAT_MULTI, sb->sb_fs_format, sb->sb_multihost_format); - printk("GFS2: I don't know how to upgrade this FS\n"); + printk(KERN_WARNING "GFS2: I don't know how to upgrade this FS\n"); return -EINVAL; } } if (!sdp->sd_args.ar_upgrade) { - printk("GFS2: code version (%u, %u) is incompatible " + printk(KERN_WARNING "GFS2: code version (%u, %u) is incompatible " "with ondisk format (%u, %u)\n", GFS2_FORMAT_FS, GFS2_FORMAT_MULTI, sb->sb_fs_format, sb->sb_multihost_format); - printk("GFS2: Use the \"upgrade\" mount option to upgrade " + printk(KERN_INFO "GFS2: Use the \"upgrade\" mount option to upgrade " "the FS\n"); - printk("GFS2: See the manual for more details\n"); + printk(KERN_INFO "GFS2: See the manual for more details\n"); return -EINVAL; } -- cgit 1.2.3-korg From 5c676f6d359b0404d53f542f02e1359583cb2895 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Mon, 27 Feb 2006 17:23:27 -0500 Subject: [GFS2] Macros removal in gfs2.h As suggested by Pekka Enberg . The DIV_RU macro is renamed DIV_ROUND_UP and and moved to kernel.h The other macros are gone from gfs2.h as (although not requested by Pekka Enberg) are a number of included header file which are now included individually. The inode number comparison function is now an inline function. The DT2IF and IF2DT may be addressed in a future patch. Signed-off-by: Steven Whitehouse --- fs/gfs2/acl.c | 8 ++++-- fs/gfs2/bits.c | 4 +++ fs/gfs2/bmap.c | 10 +++++--- fs/gfs2/daemon.c | 4 +++ fs/gfs2/dir.c | 8 ++++-- fs/gfs2/eaops.c | 4 +++ fs/gfs2/eattr.c | 19 +++++++++----- fs/gfs2/eattr.h | 2 +- fs/gfs2/gfs2.h | 29 --------------------- fs/gfs2/glock.c | 20 +++++++++------ fs/gfs2/glops.c | 21 +++++++++------ fs/gfs2/incore.h | 8 ++++++ fs/gfs2/inode.c | 38 ++++++++++++++------------- fs/gfs2/lm.c | 5 ++++ fs/gfs2/log.c | 8 ++++-- fs/gfs2/lops.c | 56 +++++++++++++++++++++++++--------------- fs/gfs2/lvb.c | 4 +++ fs/gfs2/lvb.h | 8 ------ fs/gfs2/main.c | 4 +++ fs/gfs2/meta_io.c | 37 +++++++++++++++------------ fs/gfs2/mount.c | 4 +++ fs/gfs2/ops_address.c | 34 ++++++++++++++----------- fs/gfs2/ops_dentry.c | 8 ++++-- fs/gfs2/ops_export.c | 17 ++++++++----- fs/gfs2/ops_file.c | 40 ++++++++++++++++------------- fs/gfs2/ops_fstype.c | 35 +++++++++++++++++-------- fs/gfs2/ops_inode.c | 62 ++++++++++++++++++++++++--------------------- fs/gfs2/ops_super.c | 26 +++++++++++-------- fs/gfs2/ops_vm.c | 8 ++++-- fs/gfs2/page.c | 12 ++++++--- fs/gfs2/quota.c | 20 ++++++++++----- fs/gfs2/recovery.c | 29 +++++++++++++-------- fs/gfs2/rgrp.c | 10 +++++--- fs/gfs2/super.c | 36 ++++++++++++++++---------- fs/gfs2/sys.c | 4 +++ fs/gfs2/trans.c | 19 +++++++++----- fs/gfs2/unlinked.c | 11 +++++--- fs/gfs2/util.c | 4 +++ include/linux/gfs2_ondisk.h | 11 +++++--- include/linux/kernel.h | 1 + 40 files changed, 416 insertions(+), 272 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index 9482a677ea471a..e9d05fe9435728 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c @@ -15,8 +15,11 @@ #include #include #include +#include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "acl.h" #include "eaops.h" #include "eattr.h" @@ -24,6 +27,7 @@ #include "inode.h" #include "meta_io.h" #include "trans.h" +#include "util.h" #define ACL_ACCESS 1 #define ACL_DEFAULT 0 @@ -157,7 +161,7 @@ int gfs2_check_acl_locked(struct inode *inode, int mask) struct posix_acl *acl = NULL; int error; - error = acl_get(get_v2ip(inode), ACL_ACCESS, &acl, NULL, NULL, NULL); + error = acl_get(inode->u.generic_ip, ACL_ACCESS, &acl, NULL, NULL, NULL); if (error) return error; @@ -172,7 +176,7 @@ int gfs2_check_acl_locked(struct inode *inode, int mask) int gfs2_check_acl(struct inode *inode, int mask) { - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_holder i_gh; int error; diff --git a/fs/gfs2/bits.c b/fs/gfs2/bits.c index 57d420a86adf02..49585e3de0959f 100644 --- a/fs/gfs2/bits.c +++ b/fs/gfs2/bits.c @@ -21,10 +21,14 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "bits.h" +#include "util.h" static const char valid_change[16] = { /* current */ diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index e132d8a4100887..cd5e4d863ce274 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -12,9 +12,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "bmap.h" #include "glock.h" #include "inode.h" @@ -24,6 +27,7 @@ #include "rgrp.h" #include "trans.h" #include "dir.h" +#include "util.h" /* This doesn't need to be that large as max 64 bit pointers in a 4k * block is 512, so __u16 is fine for that. It saves stack space to @@ -660,7 +664,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, for (x = 0; x < rlist.rl_rgrps; x++) { struct gfs2_rgrpd *rgd; - rgd = get_gl2rgd(rlist.rl_ghs[x].gh_gl); + rgd = rlist.rl_ghs[x].gh_gl->gl_object; rg_blocks += rgd->rd_ri.ri_length; } @@ -1021,7 +1025,7 @@ void gfs2_write_calc_reserv(struct gfs2_inode *ip, unsigned int len, unsigned int tmp; if (gfs2_is_dir(ip)) { - *data_blocks = DIV_RU(len, sdp->sd_jbsize) + 2; + *data_blocks = DIV_ROUND_UP(len, sdp->sd_jbsize) + 2; *ind_blocks = 3 * (sdp->sd_max_jheight - 1); } else { *data_blocks = (len >> sdp->sd_sb.sb_bsize_shift) + 3; @@ -1029,7 +1033,7 @@ void gfs2_write_calc_reserv(struct gfs2_inode *ip, unsigned int len, } for (tmp = *data_blocks; tmp > sdp->sd_diptrs;) { - tmp = DIV_RU(tmp, sdp->sd_inptrs); + tmp = DIV_ROUND_UP(tmp, sdp->sd_inptrs); *ind_blocks += tmp; } } diff --git a/fs/gfs2/daemon.c b/fs/gfs2/daemon.c index cff8d5368d21ce..94317dc7e42cee 100644 --- a/fs/gfs2/daemon.c +++ b/fs/gfs2/daemon.c @@ -14,9 +14,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "daemon.h" #include "glock.h" #include "log.h" @@ -24,6 +27,7 @@ #include "recovery.h" #include "super.h" #include "unlinked.h" +#include "util.h" /* This uses schedule_timeout() instead of msleep() because it's good for the daemons to wake up more often than the timeout when unmounting so diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 56683788a6cf1c..37f70ca558cc7a 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -59,9 +59,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "dir.h" #include "glock.h" #include "inode.h" @@ -70,6 +73,7 @@ #include "rgrp.h" #include "trans.h" #include "bmap.h" +#include "util.h" #define IS_LEAF 1 /* Hashed (leaf) directory */ #define IS_DINODE 2 /* Linear (stuffed dinode block) directory */ @@ -2196,7 +2200,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, uint32_t index, uint32_t len, for (x = 0; x < rlist.rl_rgrps; x++) { struct gfs2_rgrpd *rgd; - rgd = get_gl2rgd(rlist.rl_ghs[x].gh_gl); + rgd = rlist.rl_ghs[x].gh_gl->gl_object; rg_blocks += rgd->rd_ri.ri_length; } @@ -2205,7 +2209,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, uint32_t index, uint32_t len, goto out_rlist; error = gfs2_trans_begin(sdp, - rg_blocks + (DIV_RU(size, sdp->sd_jbsize) + 1) + + rg_blocks + (DIV_ROUND_UP(size, sdp->sd_jbsize) + 1) + RES_DINODE + RES_STATFS + RES_QUOTA, l_blocks); if (error) goto out_rg_gunlock; diff --git a/fs/gfs2/eaops.c b/fs/gfs2/eaops.c index 2914731250c5df..4b9f6cff7a3487 100644 --- a/fs/gfs2/eaops.c +++ b/fs/gfs2/eaops.c @@ -13,13 +13,17 @@ #include #include #include +#include #include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "acl.h" #include "eaops.h" #include "eattr.h" +#include "util.h" /** * gfs2_ea_name2type - get the type of the ea, and truncate type from the name diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c index 146995d9cd6536..8219d471f06c6e 100644 --- a/fs/gfs2/eattr.c +++ b/fs/gfs2/eattr.c @@ -13,10 +13,13 @@ #include #include #include +#include #include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "acl.h" #include "eaops.h" #include "eattr.h" @@ -26,6 +29,7 @@ #include "quota.h" #include "rgrp.h" #include "trans.h" +#include "util.h" /** * ea_calc_size - returns the acutal number of bytes the request will take up @@ -478,7 +482,7 @@ static int ea_get_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea, struct gfs2_sbd *sdp = ip->i_sbd; struct buffer_head **bh; unsigned int amount = GFS2_EA_DATA_LEN(ea); - unsigned int nptrs = DIV_RU(amount, sdp->sd_jbsize); + unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize); uint64_t *dataptrs = GFS2_EA2DATAPTRS(ea); unsigned int x; int error = 0; @@ -676,7 +680,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea, unsigned int copy; unsigned int x; - ea->ea_num_ptrs = DIV_RU(er->er_data_len, sdp->sd_jbsize); + ea->ea_num_ptrs = DIV_ROUND_UP(er->er_data_len, sdp->sd_jbsize); for (x = 0; x < ea->ea_num_ptrs; x++) { struct buffer_head *bh; uint64_t block; @@ -810,7 +814,7 @@ static int ea_init(struct gfs2_inode *ip, struct gfs2_ea_request *er) unsigned int blks = 1; if (GFS2_EAREQ_SIZE_STUFFED(er) > jbsize) - blks += DIV_RU(er->er_data_len, jbsize); + blks += DIV_ROUND_UP(er->er_data_len, jbsize); return ea_alloc_skeleton(ip, er, blks, ea_init_i, NULL); } @@ -962,7 +966,8 @@ static int ea_set_simple(struct gfs2_inode *ip, struct buffer_head *bh, es->es_bh = bh; es->es_ea = ea; - blks = 2 + DIV_RU(es->es_er->er_data_len, ip->i_sbd->sd_jbsize); + blks = 2 + DIV_ROUND_UP(es->es_er->er_data_len, + ip->i_sbd->sd_jbsize); error = ea_alloc_skeleton(ip, es->es_er, blks, ea_set_simple_alloc, es); @@ -1066,7 +1071,7 @@ static int ea_set_i(struct gfs2_inode *ip, struct gfs2_ea_request *er, if (!(ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT)) blks++; if (GFS2_EAREQ_SIZE_STUFFED(er) > ip->i_sbd->sd_jbsize) - blks += DIV_RU(er->er_data_len, ip->i_sbd->sd_jbsize); + blks += DIV_ROUND_UP(er->er_data_len, ip->i_sbd->sd_jbsize); return ea_alloc_skeleton(ip, er, blks, ea_set_block, el); } @@ -1250,7 +1255,7 @@ static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip, struct gfs2_sbd *sdp = ip->i_sbd; struct buffer_head **bh; unsigned int amount = GFS2_EA_DATA_LEN(ea); - unsigned int nptrs = DIV_RU(amount, sdp->sd_jbsize); + unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize); uint64_t *dataptrs = GFS2_EA2DATAPTRS(ea); unsigned int x; int error; @@ -1402,7 +1407,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip) for (x = 0; x < rlist.rl_rgrps; x++) { struct gfs2_rgrpd *rgd; - rgd = get_gl2rgd(rlist.rl_ghs[x].gh_gl); + rgd = rlist.rl_ghs[x].gh_gl->gl_object; rg_blocks += rgd->rd_ri.ri_length; } diff --git a/fs/gfs2/eattr.h b/fs/gfs2/eattr.h index e5a42abf68a352..2b4152b1fcbef9 100644 --- a/fs/gfs2/eattr.h +++ b/fs/gfs2/eattr.h @@ -29,7 +29,7 @@ ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + (er)->er_data_len, 8) #define GFS2_EAREQ_SIZE_UNSTUFFED(sdp, er) \ ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + \ - sizeof(uint64_t) * DIV_RU((er)->er_data_len, (sdp)->sd_jbsize), 8) + sizeof(uint64_t) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8) #define GFS2_EA2NAME(ea) ((char *)((struct gfs2_ea_header *)(ea) + 1)) #define GFS2_EA2DATA(ea) (GFS2_EA2NAME(ea) + (ea)->ea_name_len) diff --git a/fs/gfs2/gfs2.h b/fs/gfs2/gfs2.h index 6c53d080675c3c..57175f70e2bd5a 100644 --- a/fs/gfs2/gfs2.h +++ b/fs/gfs2/gfs2.h @@ -10,13 +10,6 @@ #ifndef __GFS2_DOT_H__ #define __GFS2_DOT_H__ -#include - -#include "lm_interface.h" -#include "lvb.h" -#include "incore.h" -#include "util.h" - enum { NO_CREATE = 0, CREATE = 1, @@ -32,29 +25,7 @@ enum { FORCE = 1, }; -/* Divide num by den. Round up if there is a remainder. */ -#define DIV_RU(num, den) (((num) + (den) - 1) / (den)) - #define GFS2_FAST_NAME_SIZE 8 -#define get_v2sdp(sb) ((struct gfs2_sbd *)(sb)->s_fs_info) -#define set_v2sdp(sb, sdp) (sb)->s_fs_info = (sdp) -#define get_v2ip(inode) ((struct gfs2_inode *)(inode)->u.generic_ip) -#define set_v2ip(inode, ip) (inode)->u.generic_ip = (ip) -#define get_v2fp(file) ((struct gfs2_file *)(file)->private_data) -#define set_v2fp(file, fp) (file)->private_data = (fp) -#define get_v2bd(bh) ((struct gfs2_bufdata *)(bh)->b_private) -#define set_v2bd(bh, bd) (bh)->b_private = (bd) - -#define get_transaction ((struct gfs2_trans *)(current->journal_info)) -#define set_transaction(tr) (current->journal_info) = (tr) - -#define get_gl2ip(gl) ((struct gfs2_inode *)(gl)->gl_object) -#define set_gl2ip(gl, ip) (gl)->gl_object = (ip) -#define get_gl2rgd(gl) ((struct gfs2_rgrpd *)(gl)->gl_object) -#define set_gl2rgd(gl, rgd) (gl)->gl_object = (rgd) -#define get_gl2gl(gl) ((struct gfs2_glock *)(gl)->gl_object) -#define set_gl2gl(gl, gl2) (gl)->gl_object = (gl2) - #endif /* __GFS2_DOT_H__ */ diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index f30fde91d14af5..81b06812b32967 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -16,10 +16,13 @@ #include #include #include +#include #include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "glock.h" #include "glops.h" #include "inode.h" @@ -28,6 +31,7 @@ #include "meta_io.h" #include "quota.h" #include "super.h" +#include "util.h" /* Must be kept in sync with the beginning of struct gfs2_glock */ struct glock_plug { @@ -1962,7 +1966,7 @@ void gfs2_try_toss_inode(struct gfs2_sbd *sdp, struct gfs2_inum *inum) if (!gfs2_glmutex_trylock(gl)) goto out; - ip = get_gl2ip(gl); + ip = gl->gl_object; if (!ip) goto out_unlock; @@ -1994,7 +1998,7 @@ void gfs2_iopen_go_callback(struct gfs2_glock *io_gl, unsigned int state) return; spin_lock(&io_gl->gl_spin); - i_gl = get_gl2gl(io_gl); + i_gl = io_gl->gl_object; if (i_gl) { gfs2_glock_hold(i_gl); spin_unlock(&io_gl->gl_spin); @@ -2004,7 +2008,7 @@ void gfs2_iopen_go_callback(struct gfs2_glock *io_gl, unsigned int state) } if (gfs2_glmutex_trylock(i_gl)) { - struct gfs2_inode *ip = get_gl2ip(i_gl); + struct gfs2_inode *ip = i_gl->gl_object; if (ip) { gfs2_try_toss_vnode(ip); gfs2_glmutex_unlock(i_gl); @@ -2093,7 +2097,7 @@ void gfs2_reclaim_glock(struct gfs2_sbd *sdp) if (gfs2_glmutex_trylock(gl)) { if (gl->gl_ops == &gfs2_inode_glops) { - struct gfs2_inode *ip = get_gl2ip(gl); + struct gfs2_inode *ip = gl->gl_object; if (ip && !atomic_read(&ip->i_count)) gfs2_inode_destroy(ip); } @@ -2174,7 +2178,7 @@ static void scan_glock(struct gfs2_glock *gl) { if (gfs2_glmutex_trylock(gl)) { if (gl->gl_ops == &gfs2_inode_glops) { - struct gfs2_inode *ip = get_gl2ip(gl); + struct gfs2_inode *ip = gl->gl_object; if (ip && !atomic_read(&ip->i_count)) goto out_schedule; } @@ -2234,7 +2238,7 @@ static void clear_glock(struct gfs2_glock *gl) if (gfs2_glmutex_trylock(gl)) { if (gl->gl_ops == &gfs2_inode_glops) { - struct gfs2_inode *ip = get_gl2ip(gl); + struct gfs2_inode *ip = gl->gl_object; if (ip && !atomic_read(&ip->i_count)) gfs2_inode_destroy(ip); } @@ -2430,10 +2434,10 @@ static int dump_glock(struct gfs2_glock *gl) if (error) goto out; } - if (gl->gl_ops == &gfs2_inode_glops && get_gl2ip(gl)) { + if (gl->gl_ops == &gfs2_inode_glops && gl->gl_object) { if (!test_bit(GLF_LOCK, &gl->gl_flags) && list_empty(&gl->gl_holders)) { - error = dump_inode(get_gl2ip(gl)); + error = dump_inode(gl->gl_object); if (error) goto out; } else { diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 27374306ecdede..d9334eb72df810 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -12,9 +12,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "bmap.h" #include "glock.h" #include "glops.h" @@ -24,6 +27,7 @@ #include "page.h" #include "recovery.h" #include "rgrp.h" +#include "util.h" /** * meta_go_sync - sync out the metadata for this glock @@ -193,7 +197,7 @@ static int inode_go_demote_ok(struct gfs2_glock *gl) struct gfs2_sbd *sdp = gl->gl_sbd; int demote = 0; - if (!get_gl2ip(gl) && !gl->gl_aspace->i_mapping->nrpages) + if (!gl->gl_object && !gl->gl_aspace->i_mapping->nrpages) demote = 1; else if (!sdp->sd_args.ar_localcaching && time_after_eq(jiffies, gl->gl_stamp + @@ -214,7 +218,7 @@ static int inode_go_demote_ok(struct gfs2_glock *gl) static int inode_go_lock(struct gfs2_holder *gh) { struct gfs2_glock *gl = gh->gh_gl; - struct gfs2_inode *ip = get_gl2ip(gl); + struct gfs2_inode *ip = gl->gl_object; int error = 0; if (!ip) @@ -246,7 +250,7 @@ static int inode_go_lock(struct gfs2_holder *gh) static void inode_go_unlock(struct gfs2_holder *gh) { struct gfs2_glock *gl = gh->gh_gl; - struct gfs2_inode *ip = get_gl2ip(gl); + struct gfs2_inode *ip = gl->gl_object; if (ip && test_bit(GLF_DIRTY, &gl->gl_flags)) gfs2_inode_attr_in(ip); @@ -264,7 +268,7 @@ static void inode_go_unlock(struct gfs2_holder *gh) static void inode_greedy(struct gfs2_glock *gl) { struct gfs2_sbd *sdp = gl->gl_sbd; - struct gfs2_inode *ip = get_gl2ip(gl); + struct gfs2_inode *ip = gl->gl_object; unsigned int quantum = gfs2_tune_get(sdp, gt_greedy_quantum); unsigned int max = gfs2_tune_get(sdp, gt_greedy_max); unsigned int new_time; @@ -311,7 +315,7 @@ static int rgrp_go_demote_ok(struct gfs2_glock *gl) static int rgrp_go_lock(struct gfs2_holder *gh) { - return gfs2_rgrp_bh_get(get_gl2rgd(gh->gh_gl)); + return gfs2_rgrp_bh_get(gh->gh_gl->gl_object); } /** @@ -324,7 +328,7 @@ static int rgrp_go_lock(struct gfs2_holder *gh) static void rgrp_go_unlock(struct gfs2_holder *gh) { - gfs2_rgrp_bh_put(get_gl2rgd(gh->gh_gl)); + gfs2_rgrp_bh_put(gh->gh_gl->gl_object); } /** @@ -358,13 +362,14 @@ static void trans_go_xmote_th(struct gfs2_glock *gl, unsigned int state, static void trans_go_xmote_bh(struct gfs2_glock *gl) { struct gfs2_sbd *sdp = gl->gl_sbd; - struct gfs2_glock *j_gl = get_v2ip(sdp->sd_jdesc->jd_inode)->i_gl; + struct gfs2_inode *ip = sdp->sd_jdesc->jd_inode->u.generic_ip; + struct gfs2_glock *j_gl = ip->i_gl; struct gfs2_log_header head; int error; if (gl->gl_state != LM_ST_UNLOCKED && test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) { - gfs2_meta_cache_flush(get_v2ip(sdp->sd_jdesc->jd_inode)); + gfs2_meta_cache_flush(sdp->sd_jdesc->jd_inode->u.generic_ip); j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA); error = gfs2_find_jhead(sdp->sd_jdesc, &head); diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 0e550e8e5be3a7..2443e9aad59850 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -313,6 +313,14 @@ enum { QDF_LOCKED = 2, }; +struct gfs2_quota_lvb { + uint32_t qb_magic; + uint32_t __pad; + uint64_t qb_limit; /* Hard limit of # blocks to alloc */ + uint64_t qb_warn; /* Warn user when alloc is above this # */ + int64_t qb_value; /* Current # blocks allocated */ +}; + struct gfs2_quota_data { struct list_head qd_list; unsigned int qd_count; diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 51ecdb8503b078..ea9e996f36731a 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -14,9 +14,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "acl.h" #include "bmap.h" #include "dir.h" @@ -33,6 +36,7 @@ #include "rgrp.h" #include "trans.h" #include "unlinked.h" +#include "util.h" /** * inode_attr_in - Copy attributes from the dinode into the VFS inode @@ -176,7 +180,7 @@ struct inode *gfs2_ip2v(struct gfs2_inode *ip) init_special_inode(tmp, tmp->i_mode, tmp->i_rdev); } - set_v2ip(tmp, NULL); + tmp->u.generic_ip = NULL; for (;;) { spin_lock(&ip->i_spin); @@ -196,7 +200,7 @@ struct inode *gfs2_ip2v(struct gfs2_inode *ip) gfs2_inode_hold(ip); ip->i_vnode = inode; - set_v2ip(inode, ip); + inode->u.generic_ip = ip; spin_unlock(&ip->i_spin); @@ -207,7 +211,7 @@ struct inode *gfs2_ip2v(struct gfs2_inode *ip) static int iget_test(struct inode *inode, void *opaque) { - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_inum *inum = (struct gfs2_inum *)opaque; if (ip && ip->i_num.no_addr == inum->no_addr) @@ -320,11 +324,11 @@ static int inode_create(struct gfs2_glock *i_gl, struct gfs2_inum *inum, spin_lock(&io_gl->gl_spin); gfs2_glock_hold(i_gl); - set_gl2gl(io_gl, i_gl); + io_gl->gl_object = i_gl; spin_unlock(&io_gl->gl_spin); gfs2_glock_hold(i_gl); - set_gl2ip(i_gl, ip); + i_gl->gl_object = ip; atomic_inc(&sdp->sd_inode_count); @@ -359,7 +363,7 @@ int gfs2_inode_get(struct gfs2_glock *i_gl, struct gfs2_inum *inum, int create, gfs2_glmutex_lock(i_gl); - *ipp = get_gl2ip(i_gl); + *ipp = i_gl->gl_object; if (*ipp) { error = -ESTALE; if ((*ipp)->i_num.no_formal_ino != inum->no_formal_ino) @@ -404,10 +408,10 @@ void gfs2_inode_destroy(struct gfs2_inode *ip) struct gfs2_glock *i_gl = ip->i_gl; gfs2_assert_warn(sdp, !atomic_read(&ip->i_count)); - gfs2_assert(sdp, get_gl2gl(io_gl) == i_gl); + gfs2_assert(sdp, io_gl->gl_object == i_gl); spin_lock(&io_gl->gl_spin); - set_gl2gl(io_gl, NULL); + io_gl->gl_object = NULL; gfs2_glock_put(i_gl); spin_unlock(&io_gl->gl_spin); @@ -416,7 +420,7 @@ void gfs2_inode_destroy(struct gfs2_inode *ip) gfs2_meta_cache_flush(ip); kmem_cache_free(gfs2_inode_cachep, ip); - set_gl2ip(i_gl, NULL); + i_gl->gl_object = NULL; gfs2_glock_put(i_gl); atomic_dec(&sdp->sd_inode_count); @@ -524,7 +528,7 @@ static int inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul, goto out; } - gfs2_assert_warn(sdp, !get_gl2ip(i_gh.gh_gl)); + gfs2_assert_warn(sdp, !i_gh.gh_gl->gl_object); error = inode_create(i_gh.gh_gl, &ul->ul_ut.ut_inum, io_gh->gh_gl, LM_ST_EXCLUSIVE, &ip); @@ -715,7 +719,7 @@ int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root, struct inode **inodep) { struct gfs2_inode *ipp; - struct gfs2_inode *dip = get_v2ip(dir); + struct gfs2_inode *dip = dir->u.generic_ip; struct gfs2_sbd *sdp = dip->i_sbd; struct gfs2_holder d_gh; struct gfs2_inum inum; @@ -774,7 +778,7 @@ done: static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino) { - struct gfs2_inode *ip = get_v2ip(sdp->sd_ir_inode); + struct gfs2_inode *ip = sdp->sd_ir_inode->u.generic_ip; struct buffer_head *bh; struct gfs2_inum_range ir; int error; @@ -815,8 +819,8 @@ static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino) static int pick_formal_ino_2(struct gfs2_sbd *sdp, uint64_t *formal_ino) { - struct gfs2_inode *ip = get_v2ip(sdp->sd_ir_inode); - struct gfs2_inode *m_ip = get_v2ip(sdp->sd_inum_inode); + struct gfs2_inode *ip = sdp->sd_ir_inode->u.generic_ip; + struct gfs2_inode *m_ip = sdp->sd_inum_inode->u.generic_ip; struct gfs2_holder gh; struct buffer_head *bh; struct gfs2_inum_range ir; @@ -1194,7 +1198,7 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode) { struct inode *inode; - struct gfs2_inode *dip = get_gl2ip(ghs->gh_gl); + struct gfs2_inode *dip = ghs->gh_gl->gl_object; struct gfs2_sbd *sdp = dip->i_sbd; struct gfs2_unlinked *ul; struct gfs2_inode *ip; @@ -1570,7 +1574,7 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh) { struct gfs2_glock *gl = gh->gh_gl; struct gfs2_sbd *sdp = gl->gl_sbd; - struct gfs2_inode *ip = get_gl2ip(gl); + struct gfs2_inode *ip = gl->gl_object; int64_t curtime, quantum = gfs2_tune_get(sdp, gt_atime_quantum); unsigned int state; int flags; @@ -1817,7 +1821,7 @@ int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr) { int error; - if (get_transaction) + if (current->journal_info) return __gfs2_setattr_simple(ip, attr); error = gfs2_trans_begin(ip->i_sbd, RES_DINODE, 0); diff --git a/fs/gfs2/lm.c b/fs/gfs2/lm.c index 3df8fa00442db4..5b3c56d2df2fdc 100644 --- a/fs/gfs2/lm.c +++ b/fs/gfs2/lm.c @@ -13,12 +13,17 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "glock.h" #include "lm.h" #include "super.h" +#include "util.h" +#include "lvb.h" /** * gfs2_lm_mount - mount a locking protocol diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 0e31d46edd4d19..32a41a274bf868 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -12,14 +12,18 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "bmap.h" #include "glock.h" #include "log.h" #include "lops.h" #include "meta_io.h" +#include "util.h" #define PULL 1 @@ -80,7 +84,7 @@ unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct, if (nstruct > first) { second = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header)) / ssize; - blks += DIV_RU(nstruct - first, second); + blks += DIV_ROUND_UP(nstruct - first, second); } return blks; @@ -257,7 +261,7 @@ static uint64_t log_bmap(struct gfs2_sbd *sdp, unsigned int lbn) uint64_t dbn; int error; - error = gfs2_block_map(get_v2ip(sdp->sd_jdesc->jd_inode), + error = gfs2_block_map(sdp->sd_jdesc->jd_inode->u.generic_ip, lbn, &new, &dbn, NULL); gfs2_assert_withdraw(sdp, !error && dbn); diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 4bd89c0781e73d..430161a05a21f7 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -12,9 +12,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "glock.h" #include "log.h" #include "lops.h" @@ -22,12 +25,14 @@ #include "recovery.h" #include "rgrp.h" #include "trans.h" +#include "util.h" static void glock_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) { struct gfs2_glock *gl; + struct gfs2_trans *tr = current->journal_info; - get_transaction->tr_touched = 1; + tr->tr_touched = 1; if (!list_empty(&le->le_list)) return; @@ -68,7 +73,7 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) if (!list_empty(&bd->bd_list_tr)) return; - tr = get_transaction; + tr = current->journal_info; tr->tr_touched = 1; tr->tr_num_buf++; list_add(&bd->bd_list_tr, &tr->tr_list_buf); @@ -179,7 +184,8 @@ static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) static void buf_lo_before_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head, int pass) { - struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd; + struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; + struct gfs2_sbd *sdp = ip->i_sbd; if (pass != 0) return; @@ -192,8 +198,9 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, struct gfs2_log_descriptor *ld, __be64 *ptr, int pass) { - struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd; - struct gfs2_glock *gl = get_v2ip(jd->jd_inode)->i_gl; + struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; + struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_glock *gl = ip->i_gl; unsigned int blks = be32_to_cpu(ld->ld_data1); struct buffer_head *bh_log, *bh_ip; uint64_t blkno; @@ -238,17 +245,18 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) { - struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd; + struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; + struct gfs2_sbd *sdp = ip->i_sbd; if (error) { - gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, + gfs2_meta_sync(ip->i_gl, DIO_START | DIO_WAIT); return; } if (pass != 1) return; - gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT); + gfs2_meta_sync(ip->i_gl, DIO_START | DIO_WAIT); fs_info(sdp, "jid=%u: Replayed %u of %u blocks\n", jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks); @@ -258,7 +266,7 @@ static void revoke_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) { struct gfs2_trans *tr; - tr = get_transaction; + tr = current->journal_info; tr->tr_touched = 1; tr->tr_num_revoke++; @@ -324,7 +332,8 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) static void revoke_lo_before_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head, int pass) { - struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd; + struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; + struct gfs2_sbd *sdp = ip->i_sbd; if (pass != 0) return; @@ -337,7 +346,8 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, struct gfs2_log_descriptor *ld, __be64 *ptr, int pass) { - struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd; + struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; + struct gfs2_sbd *sdp = ip->i_sbd; unsigned int blks = be32_to_cpu(ld->ld_length); unsigned int revokes = be32_to_cpu(ld->ld_data1); struct buffer_head *bh; @@ -383,7 +393,8 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) { - struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd; + struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; + struct gfs2_sbd *sdp = ip->i_sbd; if (error) { gfs2_revoke_clean(sdp); @@ -401,8 +412,9 @@ static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) static void rg_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) { struct gfs2_rgrpd *rgd; + struct gfs2_trans *tr = current->journal_info; - get_transaction->tr_touched = 1; + tr->tr_touched = 1; if (!list_empty(&le->le_list)) return; @@ -451,9 +463,9 @@ static void rg_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) { struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le); - struct gfs2_trans *tr = get_transaction; + struct gfs2_trans *tr = current->journal_info; struct address_space *mapping = bd->bd_bh->b_page->mapping; - struct gfs2_inode *ip = get_v2ip(mapping->host); + struct gfs2_inode *ip = mapping->host->u.generic_ip; tr->tr_touched = 1; if (!list_empty(&bd->bd_list_tr) && @@ -633,7 +645,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) bh = bd1->bd_bh; if (bh) { - set_v2bd(bh, NULL); + bh->b_private = NULL; gfs2_log_unlock(sdp); wait_on_buffer(bh); brelse(bh); @@ -651,8 +663,9 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, struct gfs2_log_descriptor *ld, __be64 *ptr, int pass) { - struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd; - struct gfs2_glock *gl = get_v2ip(jd->jd_inode)->i_gl; + struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; + struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_glock *gl = ip->i_gl; unsigned int blks = be32_to_cpu(ld->ld_data1); struct buffer_head *bh_log, *bh_ip; uint64_t blkno; @@ -701,10 +714,11 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) { - struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd; + struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; + struct gfs2_sbd *sdp = ip->i_sbd; if (error) { - gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, + gfs2_meta_sync(ip->i_gl, DIO_START | DIO_WAIT); return; } @@ -712,7 +726,7 @@ static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) return; /* data sync? */ - gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT); + gfs2_meta_sync(ip->i_gl, DIO_START | DIO_WAIT); fs_info(sdp, "jid=%u: Replayed %u of %u data blocks\n", jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks); diff --git a/fs/gfs2/lvb.c b/fs/gfs2/lvb.c index ca959ebb80c1ab..63b815dad8e7a6 100644 --- a/fs/gfs2/lvb.c +++ b/fs/gfs2/lvb.c @@ -12,9 +12,13 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" +#include "lvb.h" #define pv(struct, member, fmt) printk(KERN_INFO " "#member" = "fmt"\n", \ struct->member); diff --git a/fs/gfs2/lvb.h b/fs/gfs2/lvb.h index ca9732b2d9f4b7..1b9eb69b95345b 100644 --- a/fs/gfs2/lvb.h +++ b/fs/gfs2/lvb.h @@ -12,14 +12,6 @@ #define GFS2_MIN_LVB_SIZE 32 -struct gfs2_quota_lvb { - uint32_t qb_magic; - uint32_t __pad; - uint64_t qb_limit; /* Hard limit of # blocks to alloc */ - uint64_t qb_warn; /* Warn user when alloc is above this # */ - int64_t qb_value; /* Current # blocks allocated */ -}; - void gfs2_quota_lvb_in(struct gfs2_quota_lvb *qb, char *lvb); void gfs2_quota_lvb_out(struct gfs2_quota_lvb *qb, char *lvb); void gfs2_quota_lvb_print(struct gfs2_quota_lvb *qb); diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index 0c60f2b10fddd4..c54177790318b7 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c @@ -14,11 +14,15 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "ops_fstype.h" #include "sys.h" +#include "util.h" /** * init_gfs2_fs - Register GFS2 as a filesystem diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 53f33fa899f9b8..b85fa246466613 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -17,9 +17,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "glock.h" #include "glops.h" #include "inode.h" @@ -28,6 +31,7 @@ #include "meta_io.h" #include "rgrp.h" #include "trans.h" +#include "util.h" #define buffer_busy(bh) \ ((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock) | (1ul << BH_Pinned))) @@ -37,7 +41,7 @@ static int aspace_get_block(struct inode *inode, sector_t lblock, struct buffer_head *bh_result, int create) { - gfs2_assert_warn(get_v2sdp(inode->i_sb), 0); + gfs2_assert_warn(inode->i_sb->s_fs_info, 0); return -EOPNOTSUPP; } @@ -55,15 +59,15 @@ static int gfs2_aspace_writepage(struct page *page, static void stuck_releasepage(struct buffer_head *bh) { - struct gfs2_sbd *sdp = get_v2sdp(bh->b_page->mapping->host->i_sb); - struct gfs2_bufdata *bd = get_v2bd(bh); + struct gfs2_sbd *sdp = bh->b_page->mapping->host->i_sb->s_fs_info; + struct gfs2_bufdata *bd = bh->b_private; struct gfs2_glock *gl; fs_warn(sdp, "stuck in gfs2_releasepage()\n"); fs_warn(sdp, "blkno = %llu, bh->b_count = %d\n", (uint64_t)bh->b_blocknr, atomic_read(&bh->b_count)); fs_warn(sdp, "pinned = %u\n", buffer_pinned(bh)); - fs_warn(sdp, "get_v2bd(bh) = %s\n", (bd) ? "!NULL" : "NULL"); + fs_warn(sdp, "bh->b_private = %s\n", (bd) ? "!NULL" : "NULL"); if (!bd) return; @@ -78,7 +82,7 @@ static void stuck_releasepage(struct buffer_head *bh) (list_empty(&bd->bd_le.le_list)) ? "no" : "yes"); if (gl->gl_ops == &gfs2_inode_glops) { - struct gfs2_inode *ip = get_gl2ip(gl); + struct gfs2_inode *ip = gl->gl_object; unsigned int x; if (!ip) @@ -110,7 +114,7 @@ static void stuck_releasepage(struct buffer_head *bh) static int gfs2_aspace_releasepage(struct page *page, gfp_t gfp_mask) { struct inode *aspace = page->mapping->host; - struct gfs2_sbd *sdp = get_v2sdp(aspace->i_sb); + struct gfs2_sbd *sdp = aspace->i_sb->s_fs_info; struct buffer_head *bh, *head; struct gfs2_bufdata *bd; unsigned long t; @@ -139,14 +143,14 @@ static int gfs2_aspace_releasepage(struct page *page, gfp_t gfp_mask) gfs2_assert_warn(sdp, !buffer_pinned(bh)); - bd = get_v2bd(bh); + bd = bh->b_private; if (bd) { gfs2_assert_warn(sdp, bd->bd_bh == bh); gfs2_assert_warn(sdp, list_empty(&bd->bd_list_tr)); gfs2_assert_warn(sdp, list_empty(&bd->bd_le.le_list)); gfs2_assert_warn(sdp, !bd->bd_ail); kmem_cache_free(gfs2_bufdata_cachep, bd); - set_v2bd(bh, NULL); + bh->b_private = NULL; } bh = bh->b_this_page; @@ -184,7 +188,7 @@ struct inode *gfs2_aspace_get(struct gfs2_sbd *sdp) mapping_set_gfp_mask(aspace->i_mapping, GFP_KERNEL); aspace->i_mapping->a_ops = &aspace_aops; aspace->i_size = ~0ULL; - set_v2ip(aspace, NULL); + aspace->u.generic_ip = NULL; insert_inode_hash(aspace); } @@ -523,7 +527,7 @@ int gfs2_meta_reread(struct gfs2_sbd *sdp, struct buffer_head *bh, int flags) wait_on_buffer(bh); if (!buffer_uptodate(bh)) { - struct gfs2_trans *tr = get_transaction; + struct gfs2_trans *tr = current->journal_info; if (tr && tr->tr_touched) gfs2_io_error_bh(sdp, bh); return -EIO; @@ -550,7 +554,7 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh, if (meta) lock_page(bh->b_page); - if (get_v2bd(bh)) { + if (bh->b_private) { if (meta) unlock_page(bh->b_page); return; @@ -569,7 +573,7 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh, lops_init_le(&bd->bd_le, &gfs2_databuf_lops); get_bh(bh); } - set_v2bd(bh, bd); + bh->b_private = bd; if (meta) unlock_page(bh->b_page); @@ -584,7 +588,7 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh, void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh) { - struct gfs2_bufdata *bd = get_v2bd(bh); + struct gfs2_bufdata *bd = bh->b_private; gfs2_assert_withdraw(sdp, test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)); @@ -621,7 +625,7 @@ void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh) void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh, struct gfs2_ail *ai) { - struct gfs2_bufdata *bd = get_v2bd(bh); + struct gfs2_bufdata *bd = bh->b_private; gfs2_assert_withdraw(sdp, buffer_uptodate(bh)); @@ -662,15 +666,16 @@ void gfs2_meta_wipe(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen) while (blen) { bh = getbuf(sdp, aspace, bstart, NO_CREATE); if (bh) { - struct gfs2_bufdata *bd = get_v2bd(bh); + struct gfs2_bufdata *bd = bh->b_private; if (test_clear_buffer_pinned(bh)) { + struct gfs2_trans *tr = current->journal_info; gfs2_log_lock(sdp); list_del_init(&bd->bd_le.le_list); gfs2_assert_warn(sdp, sdp->sd_log_num_buf); sdp->sd_log_num_buf--; gfs2_log_unlock(sdp); - get_transaction->tr_num_buf_rm++; + tr->tr_num_buf_rm++; brelse(bh); } if (bd) { diff --git a/fs/gfs2/mount.c b/fs/gfs2/mount.c index 3e42697aafc74d..e90ea7d32f9ec1 100644 --- a/fs/gfs2/mount.c +++ b/fs/gfs2/mount.c @@ -12,11 +12,15 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "mount.h" #include "sys.h" +#include "util.h" /** * gfs2_mount_args - Parse mount options diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 89a8b8fad2e7e9..01aa4a9b48c394 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -15,9 +15,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "bmap.h" #include "glock.h" #include "inode.h" @@ -29,6 +32,7 @@ #include "trans.h" #include "rgrp.h" #include "ops_file.h" +#include "util.h" /** * gfs2_get_block - Fills in a buffer head with details about a block @@ -43,7 +47,7 @@ int gfs2_get_block(struct inode *inode, sector_t lblock, struct buffer_head *bh_result, int create) { - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; int new = create; uint64_t dblock; int error; @@ -75,7 +79,7 @@ int gfs2_get_block(struct inode *inode, sector_t lblock, static int get_block_noalloc(struct inode *inode, sector_t lblock, struct buffer_head *bh_result, int create) { - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; int new = 0; uint64_t dblock; int error; @@ -96,7 +100,7 @@ static int get_blocks(struct inode *inode, sector_t lblock, unsigned long max_blocks, struct buffer_head *bh_result, int create) { - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; int new = create; uint64_t dblock; uint32_t extlen; @@ -124,7 +128,7 @@ static int get_blocks_noalloc(struct inode *inode, sector_t lblock, unsigned long max_blocks, struct buffer_head *bh_result, int create) { - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; int new = 0; uint64_t dblock; uint32_t extlen; @@ -158,7 +162,7 @@ static int get_blocks_noalloc(struct inode *inode, sector_t lblock, static int gfs2_writepage(struct page *page, struct writeback_control *wbc) { struct inode *inode = page->mapping->host; - struct gfs2_inode *ip = get_v2ip(page->mapping->host); + struct gfs2_inode *ip = page->mapping->host->u.generic_ip; struct gfs2_sbd *sdp = ip->i_sbd; loff_t i_size = i_size_read(inode); pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT; @@ -170,7 +174,7 @@ static int gfs2_writepage(struct page *page, struct writeback_control *wbc) unlock_page(page); return -EIO; } - if (get_transaction) + if (current->journal_info) goto out_ignore; /* Is the page fully outside i_size? (truncate in progress) */ @@ -259,7 +263,7 @@ static int zero_readpage(struct page *page) static int gfs2_readpage(struct file *file, struct page *page) { - struct gfs2_inode *ip = get_v2ip(page->mapping->host); + struct gfs2_inode *ip = page->mapping->host->u.generic_ip; struct gfs2_sbd *sdp = ip->i_sbd; struct gfs2_holder gh; int error; @@ -307,7 +311,7 @@ out_unlock: static int gfs2_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to) { - struct gfs2_inode *ip = get_v2ip(page->mapping->host); + struct gfs2_inode *ip = page->mapping->host->u.generic_ip; struct gfs2_sbd *sdp = ip->i_sbd; unsigned int data_blocks, ind_blocks, rblocks; int alloc_required; @@ -402,7 +406,7 @@ static int gfs2_commit_write(struct file *file, struct page *page, unsigned from, unsigned to) { struct inode *inode = page->mapping->host; - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_sbd *sdp = ip->i_sbd; int error = -EOPNOTSUPP; struct buffer_head *dibh; @@ -482,7 +486,7 @@ fail_nounlock: static sector_t gfs2_bmap(struct address_space *mapping, sector_t lblock) { - struct gfs2_inode *ip = get_v2ip(mapping->host); + struct gfs2_inode *ip = mapping->host->u.generic_ip; struct gfs2_holder i_gh; sector_t dblock = 0; int error; @@ -504,10 +508,10 @@ static void discard_buffer(struct gfs2_sbd *sdp, struct buffer_head *bh) struct gfs2_bufdata *bd; gfs2_log_lock(sdp); - bd = get_v2bd(bh); + bd = bh->b_private; if (bd) { bd->bd_bh = NULL; - set_v2bd(bh, NULL); + bh->b_private = NULL; gfs2_log_unlock(sdp); brelse(bh); } else @@ -525,7 +529,7 @@ static void discard_buffer(struct gfs2_sbd *sdp, struct buffer_head *bh) static int gfs2_invalidatepage(struct page *page, unsigned long offset) { - struct gfs2_sbd *sdp = get_v2sdp(page->mapping->host->i_sb); + struct gfs2_sbd *sdp = page->mapping->host->i_sb->s_fs_info; struct buffer_head *head, *bh, *next; unsigned int curr_off = 0; int ret = 1; @@ -557,7 +561,7 @@ static ssize_t gfs2_direct_IO_write(struct kiocb *iocb, const struct iovec *iov, { struct file *file = iocb->ki_filp; struct inode *inode = file->f_mapping->host; - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_holder gh; int rv; @@ -604,7 +608,7 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb, { struct file *file = iocb->ki_filp; struct inode *inode = file->f_mapping->host; - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_sbd *sdp = ip->i_sbd; if (rw == WRITE) diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c index b020ad8f180b95..7f61392885194b 100644 --- a/fs/gfs2/ops_dentry.c +++ b/fs/gfs2/ops_dentry.c @@ -13,12 +13,16 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "dir.h" #include "glock.h" #include "ops_dentry.h" +#include "util.h" /** * gfs2_drevalidate - Check directory lookup consistency @@ -34,7 +38,7 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd) { struct dentry *parent = dget_parent(dentry); - struct gfs2_inode *dip = get_v2ip(parent->d_inode); + struct gfs2_inode *dip = parent->d_inode->u.generic_ip; struct inode *inode; struct gfs2_holder d_gh; struct gfs2_inode *ip; @@ -66,7 +70,7 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd) goto fail_gunlock; } - ip = get_v2ip(inode); + ip = inode->u.generic_ip; if (!gfs2_inum_equal(&ip->i_num, &inum)) goto invalid_gunlock; diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index 60d006402553f9..d149584cff301e 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c @@ -12,9 +12,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "dir.h" #include "glock.h" #include "glops.h" @@ -61,7 +64,7 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len, int connectable) { struct inode *inode = dentry->d_inode; - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_sbd *sdp = ip->i_sbd; if (*len < 4 || (connectable && *len < 8)) @@ -77,12 +80,12 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len, fh[3] = cpu_to_be32(fh[3]); *len = 4; - if (!connectable || ip == get_v2ip(sdp->sd_root_dir)) + if (!connectable || ip == sdp->sd_root_dir->u.generic_ip) return *len; spin_lock(&dentry->d_lock); inode = dentry->d_parent->d_inode; - ip = get_v2ip(inode); + ip = inode->u.generic_ip; gfs2_inode_hold(ip); spin_unlock(&dentry->d_lock); @@ -138,8 +141,8 @@ static int gfs2_get_name(struct dentry *parent, char *name, if (!S_ISDIR(dir->i_mode) || !inode) return -EINVAL; - dip = get_v2ip(dir); - ip = get_v2ip(inode); + dip = dir->u.generic_ip; + ip = inode->u.generic_ip; *name = 0; gnfd.inum = ip->i_num; @@ -181,7 +184,7 @@ static struct dentry *gfs2_get_parent(struct dentry *child) static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_p) { - struct gfs2_sbd *sdp = get_v2sdp(sb); + struct gfs2_sbd *sdp = sb->s_fs_info; struct gfs2_inum *inum = (struct gfs2_inum *)inum_p; struct gfs2_holder i_gh, ri_gh, rgd_gh; struct gfs2_rgrpd *rgd; @@ -194,7 +197,7 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_p) inode = gfs2_iget(sb, inum); if (inode) { - ip = get_v2ip(inode); + ip = inode->u.generic_ip; if (ip->i_num.no_formal_ino != inum->no_formal_ino) { iput(inode); return ERR_PTR(-ESTALE); diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index e6ae2551b0cb09..d30c6db46241dc 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c @@ -19,10 +19,13 @@ #include #include #include +#include #include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "bmap.h" #include "dir.h" #include "glock.h" @@ -36,6 +39,7 @@ #include "quota.h" #include "rgrp.h" #include "trans.h" +#include "util.h" /* "bad" is for NFS support */ struct filldir_bad_entry { @@ -125,7 +129,7 @@ int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state, static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin) { - struct gfs2_inode *ip = get_v2ip(file->f_mapping->host); + struct gfs2_inode *ip = file->f_mapping->host->u.generic_ip; struct gfs2_holder i_gh; loff_t error; @@ -172,7 +176,7 @@ static ssize_t __gfs2_file_aio_read(struct kiocb *iocb, unsigned long nr_segs, loff_t *ppos) { struct file *filp = iocb->ki_filp; - struct gfs2_inode *ip = get_v2ip(filp->f_mapping->host); + struct gfs2_inode *ip = filp->f_mapping->host->u.generic_ip; struct gfs2_holder gh; ssize_t retval; unsigned long seg; @@ -354,7 +358,7 @@ static int filldir_reg_func(void *opaque, const char *name, unsigned int length, static int readdir_reg(struct file *file, void *dirent, filldir_t filldir) { - struct gfs2_inode *dip = get_v2ip(file->f_mapping->host); + struct gfs2_inode *dip = file->f_mapping->host->u.generic_ip; struct filldir_reg fdr; struct gfs2_holder d_gh; uint64_t offset = file->f_pos; @@ -443,7 +447,7 @@ static int filldir_bad_func(void *opaque, const char *name, unsigned int length, static int readdir_bad(struct file *file, void *dirent, filldir_t filldir) { - struct gfs2_inode *dip = get_v2ip(file->f_mapping->host); + struct gfs2_inode *dip = file->f_mapping->host->u.generic_ip; struct gfs2_sbd *sdp = dip->i_sbd; struct filldir_reg fdr; unsigned int entries, size; @@ -608,7 +612,7 @@ out: static int gfs2_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; switch (cmd) { case GFS2_IOCTL_SETFLAGS: @@ -630,7 +634,7 @@ static int gfs2_ioctl(struct inode *inode, struct file *file, unsigned int cmd, static int gfs2_mmap(struct file *file, struct vm_area_struct *vma) { - struct gfs2_inode *ip = get_v2ip(file->f_mapping->host); + struct gfs2_inode *ip = file->f_mapping->host->u.generic_ip; struct gfs2_holder i_gh; int error; @@ -665,7 +669,7 @@ static int gfs2_mmap(struct file *file, struct vm_area_struct *vma) static int gfs2_open(struct inode *inode, struct file *file) { - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_holder i_gh; struct gfs2_file *fp; int error; @@ -679,8 +683,8 @@ static int gfs2_open(struct inode *inode, struct file *file) fp->f_inode = ip; fp->f_vfile = file; - gfs2_assert_warn(ip->i_sbd, !get_v2fp(file)); - set_v2fp(file, fp); + gfs2_assert_warn(ip->i_sbd, !file->private_data); + file->private_data = fp; if (S_ISREG(ip->i_di.di_mode)) { error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, @@ -708,7 +712,7 @@ static int gfs2_open(struct inode *inode, struct file *file) gfs2_glock_dq_uninit(&i_gh); fail: - set_v2fp(file, NULL); + file->private_data = NULL; kfree(fp); return error; @@ -724,11 +728,11 @@ static int gfs2_open(struct inode *inode, struct file *file) static int gfs2_close(struct inode *inode, struct file *file) { - struct gfs2_sbd *sdp = get_v2sdp(inode->i_sb); + struct gfs2_sbd *sdp = inode->i_sb->s_fs_info; struct gfs2_file *fp; - fp = get_v2fp(file); - set_v2fp(file, NULL); + fp = file->private_data; + file->private_data = NULL; if (gfs2_assert_warn(sdp, fp)) return -EIO; @@ -748,7 +752,7 @@ static int gfs2_close(struct inode *inode, struct file *file) static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync) { - struct gfs2_inode *ip = get_v2ip(dentry->d_inode); + struct gfs2_inode *ip = dentry->d_inode->u.generic_ip; gfs2_log_flush_glock(ip->i_gl); @@ -766,7 +770,7 @@ static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync) static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) { - struct gfs2_inode *ip = get_v2ip(file->f_mapping->host); + struct gfs2_inode *ip = file->f_mapping->host->u.generic_ip; struct gfs2_sbd *sdp = ip->i_sbd; struct lm_lockname name = { .ln_number = ip->i_num.no_addr, @@ -824,7 +828,7 @@ static ssize_t gfs2_sendfile(struct file *in_file, loff_t *offset, size_t count, static int do_flock(struct file *file, int cmd, struct file_lock *fl) { - struct gfs2_file *fp = get_v2fp(file); + struct gfs2_file *fp = file->private_data; struct gfs2_holder *fl_gh = &fp->f_fl_gh; struct gfs2_inode *ip = fp->f_inode; struct gfs2_glock *gl; @@ -874,7 +878,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) static void do_unflock(struct file *file, struct file_lock *fl) { - struct gfs2_file *fp = get_v2fp(file); + struct gfs2_file *fp = file->private_data; struct gfs2_holder *fl_gh = &fp->f_fl_gh; mutex_lock(&fp->f_fl_mutex); @@ -895,7 +899,7 @@ static void do_unflock(struct file *file, struct file_lock *fl) static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl) { - struct gfs2_inode *ip = get_v2ip(file->f_mapping->host); + struct gfs2_inode *ip = file->f_mapping->host->u.generic_ip; struct gfs2_sbd *sdp = ip->i_sbd; if (!(fl->fl_flags & FL_FLOCK)) diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 535f020f1e0cfa..4c4115f9d960f7 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -15,9 +15,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "daemon.h" #include "glock.h" #include "glops.h" @@ -32,6 +35,7 @@ #include "super.h" #include "unlinked.h" #include "sys.h" +#include "util.h" #define DO 0 #define UNDO 1 @@ -47,7 +51,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb) memset(sdp, 0, sizeof(struct gfs2_sbd)); - set_v2sdp(sb, sdp); + sb->s_fs_info = sdp; sdp->sd_vfs = sb; gfs2_tune_init(&sdp->sd_tune); @@ -382,6 +386,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) { struct gfs2_holder ji_gh; struct task_struct *p; + struct gfs2_inode *ip; int jindex = 1; int error = 0; @@ -396,7 +401,8 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) fs_err(sdp, "can't lookup journal index: %d\n", error); return error; } - set_bit(GLF_STICKY, &get_v2ip(sdp->sd_jindex)->i_gl->gl_flags); + ip = sdp->sd_jindex->u.generic_ip; + set_bit(GLF_STICKY, &ip->i_gl->gl_flags); /* Load in the journal index special file */ @@ -436,8 +442,8 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) goto fail_jindex; } - error = gfs2_glock_nq_init( - get_v2ip(sdp->sd_jdesc->jd_inode)->i_gl, + ip = sdp->sd_jdesc->jd_inode->u.generic_ip; + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_NOEXP | GL_EXACT, &sdp->sd_jinode_gh); @@ -522,6 +528,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) static int init_inodes(struct gfs2_sbd *sdp, int undo) { int error = 0; + struct gfs2_inode *ip; if (undo) goto fail_qinode; @@ -560,8 +567,9 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo) fs_err(sdp, "can't get resource index inode: %d\n", error); goto fail_statfs; } - set_bit(GLF_STICKY, &get_v2ip(sdp->sd_rindex)->i_gl->gl_flags); - sdp->sd_rindex_vn = get_v2ip(sdp->sd_rindex)->i_gl->gl_vn - 1; + ip = sdp->sd_rindex->u.generic_ip; + set_bit(GLF_STICKY, &ip->i_gl->gl_flags); + sdp->sd_rindex_vn = ip->i_gl->gl_vn - 1; /* Read in the quota inode */ error = gfs2_lookup_simple(sdp->sd_master_dir, "quota", @@ -597,6 +605,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) struct inode *pn = NULL; char buf[30]; int error = 0; + struct gfs2_inode *ip; if (sdp->sd_args.ar_spectator) return 0; @@ -641,7 +650,8 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) iput(pn); pn = NULL; - error = gfs2_glock_nq_init(get_v2ip(sdp->sd_ir_inode)->i_gl, + ip = sdp->sd_ir_inode->u.generic_ip; + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_NEVER_RECURSE, &sdp->sd_ir_gh); if (error) { @@ -649,7 +659,8 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) goto fail_qc_i; } - error = gfs2_glock_nq_init(get_v2ip(sdp->sd_sc_inode)->i_gl, + ip = sdp->sd_sc_inode->u.generic_ip; + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_NEVER_RECURSE, &sdp->sd_sc_gh); if (error) { @@ -657,7 +668,8 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) goto fail_ir_gh; } - error = gfs2_glock_nq_init(get_v2ip(sdp->sd_ut_inode)->i_gl, + ip = sdp->sd_ut_inode->u.generic_ip; + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_NEVER_RECURSE, &sdp->sd_ut_gh); if (error) { @@ -665,7 +677,8 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) goto fail_sc_gh; } - error = gfs2_glock_nq_init(get_v2ip(sdp->sd_qc_inode)->i_gl, + ip = sdp->sd_qc_inode->u.generic_ip; + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_NEVER_RECURSE, &sdp->sd_qc_gh); if (error) { @@ -862,7 +875,7 @@ static int fill_super(struct super_block *sb, void *data, int silent) fail: vfree(sdp); - set_v2sdp(sb, NULL); + sb->s_fs_info = NULL; return error; } diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 9971a30eb78ec3..7633a8584b0db2 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -17,10 +17,13 @@ #include #include #include +#include #include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "acl.h" #include "bmap.h" #include "dir.h" @@ -36,6 +39,7 @@ #include "rgrp.h" #include "trans.h" #include "unlinked.h" +#include "util.h" /** * gfs2_create - Create a file @@ -49,7 +53,7 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) { - struct gfs2_inode *dip = get_v2ip(dir); + struct gfs2_inode *dip = dir->u.generic_ip; struct gfs2_sbd *sdp = dip->i_sbd; struct gfs2_holder ghs[2]; struct inode *inode; @@ -106,7 +110,7 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry, static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) { - struct gfs2_inode *dip = get_v2ip(dir); + struct gfs2_inode *dip = dir->u.generic_ip; struct gfs2_sbd *sdp = dip->i_sbd; struct inode *inode = NULL; int error; @@ -140,10 +144,10 @@ static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry, static int gfs2_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) { - struct gfs2_inode *dip = get_v2ip(dir); + struct gfs2_inode *dip = dir->u.generic_ip; struct gfs2_sbd *sdp = dip->i_sbd; struct inode *inode = old_dentry->d_inode; - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_holder ghs[2]; int alloc_required; int error; @@ -274,9 +278,9 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, static int gfs2_unlink(struct inode *dir, struct dentry *dentry) { - struct gfs2_inode *dip = get_v2ip(dir); + struct gfs2_inode *dip = dir->u.generic_ip; struct gfs2_sbd *sdp = dip->i_sbd; - struct gfs2_inode *ip = get_v2ip(dentry->d_inode); + struct gfs2_inode *ip = dentry->d_inode->u.generic_ip; struct gfs2_unlinked *ul; struct gfs2_holder ghs[2]; int error; @@ -329,7 +333,7 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry) static int gfs2_symlink(struct inode *dir, struct dentry *dentry, const char *symname) { - struct gfs2_inode *dip = get_v2ip(dir), *ip; + struct gfs2_inode *dip = dir->u.generic_ip, *ip; struct gfs2_sbd *sdp = dip->i_sbd; struct gfs2_holder ghs[2]; struct inode *inode; @@ -350,7 +354,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry, return PTR_ERR(inode); } - ip = get_gl2ip(ghs[1].gh_gl); + ip = ghs[1].gh_gl->gl_object; ip->i_di.di_size = size; @@ -388,7 +392,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry, static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode) { - struct gfs2_inode *dip = get_v2ip(dir), *ip; + struct gfs2_inode *dip = dir->u.generic_ip, *ip; struct gfs2_sbd *sdp = dip->i_sbd; struct gfs2_holder ghs[2]; struct inode *inode; @@ -403,7 +407,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode) return PTR_ERR(inode); } - ip = get_gl2ip(ghs[1].gh_gl); + ip = ghs[1].gh_gl->gl_object; ip->i_di.di_nlink = 2; ip->i_di.di_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode); @@ -468,9 +472,9 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode) static int gfs2_rmdir(struct inode *dir, struct dentry *dentry) { - struct gfs2_inode *dip = get_v2ip(dir); + struct gfs2_inode *dip = dir->u.generic_ip; struct gfs2_sbd *sdp = dip->i_sbd; - struct gfs2_inode *ip = get_v2ip(dentry->d_inode); + struct gfs2_inode *ip = dentry->d_inode->u.generic_ip; struct gfs2_unlinked *ul; struct gfs2_holder ghs[2]; int error; @@ -534,7 +538,7 @@ static int gfs2_rmdir(struct inode *dir, struct dentry *dentry) static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) { - struct gfs2_inode *dip = get_v2ip(dir), *ip; + struct gfs2_inode *dip = dir->u.generic_ip, *ip; struct gfs2_sbd *sdp = dip->i_sbd; struct gfs2_holder ghs[2]; struct inode *inode; @@ -563,7 +567,7 @@ static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, return PTR_ERR(inode); } - ip = get_gl2ip(ghs[1].gh_gl); + ip = ghs[1].gh_gl->gl_object; ip->i_di.di_major = major; ip->i_di.di_minor = minor; @@ -602,9 +606,9 @@ static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, static int gfs2_rename(struct inode *odir, struct dentry *odentry, struct inode *ndir, struct dentry *ndentry) { - struct gfs2_inode *odip = get_v2ip(odir); - struct gfs2_inode *ndip = get_v2ip(ndir); - struct gfs2_inode *ip = get_v2ip(odentry->d_inode); + struct gfs2_inode *odip = odir->u.generic_ip; + struct gfs2_inode *ndip = ndir->u.generic_ip; + struct gfs2_inode *ip = odentry->d_inode->u.generic_ip; struct gfs2_inode *nip = NULL; struct gfs2_sbd *sdp = odip->i_sbd; struct gfs2_unlinked *ul; @@ -616,7 +620,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, int error; if (ndentry->d_inode) { - nip = get_v2ip(ndentry->d_inode); + nip = ndentry->d_inode->u.generic_ip; if (ip == nip) return 0; } @@ -848,7 +852,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, static int gfs2_readlink(struct dentry *dentry, char __user *user_buf, int user_size) { - struct gfs2_inode *ip = get_v2ip(dentry->d_inode); + struct gfs2_inode *ip = dentry->d_inode->u.generic_ip; char array[GFS2_FAST_NAME_SIZE], *buf = array; unsigned int len = GFS2_FAST_NAME_SIZE; int error; @@ -884,7 +888,7 @@ static int gfs2_readlink(struct dentry *dentry, char __user *user_buf, static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd) { - struct gfs2_inode *ip = get_v2ip(dentry->d_inode); + struct gfs2_inode *ip = dentry->d_inode->u.generic_ip; char array[GFS2_FAST_NAME_SIZE], *buf = array; unsigned int len = GFS2_FAST_NAME_SIZE; int error; @@ -910,7 +914,7 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd) static int gfs2_permission(struct inode *inode, int mask, struct nameidata *nd) { - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_holder i_gh; int error; @@ -930,7 +934,7 @@ static int gfs2_permission(struct inode *inode, int mask, struct nameidata *nd) static int setattr_size(struct inode *inode, struct iattr *attr) { - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; int error; if (attr->ia_size != ip->i_di.di_size) { @@ -948,7 +952,7 @@ static int setattr_size(struct inode *inode, struct iattr *attr) static int setattr_chown(struct inode *inode, struct iattr *attr) { - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_sbd *sdp = ip->i_sbd; struct buffer_head *dibh; uint32_t ouid, ogid, nuid, ngid; @@ -1025,7 +1029,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr) static int gfs2_setattr(struct dentry *dentry, struct iattr *attr) { struct inode *inode = dentry->d_inode; - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_holder i_gh; int error; @@ -1072,7 +1076,7 @@ static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) { struct inode *inode = dentry->d_inode; - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_holder gh; int error; @@ -1088,7 +1092,7 @@ static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, static int gfs2_setxattr(struct dentry *dentry, const char *name, const void *data, size_t size, int flags) { - struct gfs2_inode *ip = get_v2ip(dentry->d_inode); + struct gfs2_inode *ip = dentry->d_inode->u.generic_ip; struct gfs2_ea_request er; memset(&er, 0, sizeof(struct gfs2_ea_request)); @@ -1118,7 +1122,7 @@ static ssize_t gfs2_getxattr(struct dentry *dentry, const char *name, er.er_name_len = strlen(er.er_name); er.er_data_len = size; - return gfs2_ea_get(get_v2ip(dentry->d_inode), &er); + return gfs2_ea_get(dentry->d_inode->u.generic_ip, &er); } static ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size) @@ -1129,7 +1133,7 @@ static ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size) er.er_data = (size) ? buffer : NULL; er.er_data_len = size; - return gfs2_ea_list(get_v2ip(dentry->d_inode), &er); + return gfs2_ea_list(dentry->d_inode->u.generic_ip, &er); } static int gfs2_removexattr(struct dentry *dentry, const char *name) @@ -1142,7 +1146,7 @@ static int gfs2_removexattr(struct dentry *dentry, const char *name) return -EOPNOTSUPP; er.er_name_len = strlen(er.er_name); - return gfs2_ea_remove(get_v2ip(dentry->d_inode), &er); + return gfs2_ea_remove(dentry->d_inode->u.generic_ip, &er); } struct inode_operations gfs2_file_iops = { diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 48a94522406ea5..10f70ee121613b 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -18,9 +18,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "glock.h" #include "inode.h" #include "lm.h" @@ -33,6 +36,7 @@ #include "rgrp.h" #include "super.h" #include "sys.h" +#include "util.h" /** * gfs2_write_inode - Make sure the inode is stable on the disk @@ -44,7 +48,7 @@ static int gfs2_write_inode(struct inode *inode, int sync) { - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; if (current->flags & PF_MEMALLOC) return 0; @@ -62,7 +66,7 @@ static int gfs2_write_inode(struct inode *inode, int sync) static void gfs2_put_super(struct super_block *sb) { - struct gfs2_sbd *sdp = get_v2sdp(sb); + struct gfs2_sbd *sdp = sb->s_fs_info; int error; if (!sdp) @@ -138,7 +142,7 @@ static void gfs2_put_super(struct super_block *sb) vfree(sdp); - set_v2sdp(sb, NULL); + sb->s_fs_info = NULL; } /** @@ -151,7 +155,7 @@ static void gfs2_put_super(struct super_block *sb) static void gfs2_write_super(struct super_block *sb) { - struct gfs2_sbd *sdp = get_v2sdp(sb); + struct gfs2_sbd *sdp = sb->s_fs_info; gfs2_log_flush(sdp); } @@ -163,7 +167,7 @@ static void gfs2_write_super(struct super_block *sb) static void gfs2_write_super_lockfs(struct super_block *sb) { - struct gfs2_sbd *sdp = get_v2sdp(sb); + struct gfs2_sbd *sdp = sb->s_fs_info; int error; for (;;) { @@ -194,7 +198,7 @@ static void gfs2_write_super_lockfs(struct super_block *sb) static void gfs2_unlockfs(struct super_block *sb) { - struct gfs2_sbd *sdp = get_v2sdp(sb); + struct gfs2_sbd *sdp = sb->s_fs_info; gfs2_unfreeze_fs(sdp); } @@ -208,7 +212,7 @@ static void gfs2_unlockfs(struct super_block *sb) static int gfs2_statfs(struct super_block *sb, struct kstatfs *buf) { - struct gfs2_sbd *sdp = get_v2sdp(sb); + struct gfs2_sbd *sdp = sb->s_fs_info; struct gfs2_statfs_change sc; int error; @@ -245,7 +249,7 @@ static int gfs2_statfs(struct super_block *sb, struct kstatfs *buf) static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data) { - struct gfs2_sbd *sdp = get_v2sdp(sb); + struct gfs2_sbd *sdp = sb->s_fs_info; int error; error = gfs2_mount_args(sdp, data, 1); @@ -283,12 +287,12 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data) static void gfs2_clear_inode(struct inode *inode) { - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; if (ip) { spin_lock(&ip->i_spin); ip->i_vnode = NULL; - set_v2ip(inode, NULL); + inode->u.generic_ip = NULL; spin_unlock(&ip->i_spin); gfs2_glock_schedule_for_reclaim(ip->i_gl); @@ -306,7 +310,7 @@ static void gfs2_clear_inode(struct inode *inode) static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) { - struct gfs2_sbd *sdp = get_v2sdp(mnt->mnt_sb); + struct gfs2_sbd *sdp = mnt->mnt_sb->s_fs_info; struct gfs2_args *args = &sdp->sd_args; if (args->ar_lockproto[0]) diff --git a/fs/gfs2/ops_vm.c b/fs/gfs2/ops_vm.c index bfeb920dccee11..dbc57071e7bb4c 100644 --- a/fs/gfs2/ops_vm.c +++ b/fs/gfs2/ops_vm.c @@ -14,9 +14,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "bmap.h" #include "glock.h" #include "inode.h" @@ -25,6 +28,7 @@ #include "quota.h" #include "rgrp.h" #include "trans.h" +#include "util.h" static void pfault_be_greedy(struct gfs2_inode *ip) { @@ -43,7 +47,7 @@ static void pfault_be_greedy(struct gfs2_inode *ip) static struct page *gfs2_private_nopage(struct vm_area_struct *area, unsigned long address, int *type) { - struct gfs2_inode *ip = get_v2ip(area->vm_file->f_mapping->host); + struct gfs2_inode *ip = area->vm_file->f_mapping->host->u.generic_ip; struct gfs2_holder i_gh; struct page *result; int error; @@ -141,7 +145,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page) static struct page *gfs2_sharewrite_nopage(struct vm_area_struct *area, unsigned long address, int *type) { - struct gfs2_inode *ip = get_v2ip(area->vm_file->f_mapping->host); + struct gfs2_inode *ip = area->vm_file->f_mapping->host->u.generic_ip; struct gfs2_holder i_gh; struct page *result = NULL; unsigned long index = ((address - area->vm_start) >> PAGE_CACHE_SHIFT) + diff --git a/fs/gfs2/page.c b/fs/gfs2/page.c index 3542aa6b01c435..a2c9e93c7c391e 100644 --- a/fs/gfs2/page.c +++ b/fs/gfs2/page.c @@ -14,14 +14,18 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "bmap.h" #include "inode.h" #include "page.h" #include "trans.h" #include "ops_address.h" +#include "util.h" /** * gfs2_pte_inval - Sync and invalidate all PTEs associated with a glock @@ -34,7 +38,7 @@ void gfs2_pte_inval(struct gfs2_glock *gl) struct gfs2_inode *ip; struct inode *inode; - ip = get_gl2ip(gl); + ip = gl->gl_object; if (!ip || !S_ISREG(ip->i_di.di_mode)) return; @@ -64,7 +68,7 @@ void gfs2_page_inval(struct gfs2_glock *gl) struct gfs2_inode *ip; struct inode *inode; - ip = get_gl2ip(gl); + ip = gl->gl_object; if (!ip || !S_ISREG(ip->i_di.di_mode)) return; @@ -95,7 +99,7 @@ void gfs2_page_sync(struct gfs2_glock *gl, int flags) struct gfs2_inode *ip; struct inode *inode; - ip = get_gl2ip(gl); + ip = gl->gl_object; if (!ip || !S_ISREG(ip->i_di.di_mode)) return; @@ -192,7 +196,7 @@ int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, int gfs2_block_truncate_page(struct address_space *mapping) { struct inode *inode = mapping->host; - struct gfs2_inode *ip = get_v2ip(inode); + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_sbd *sdp = ip->i_sbd; loff_t from = inode->i_size; unsigned long index = from >> PAGE_CACHE_SHIFT; diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 40c7cf87eb441c..c57b5cf1d583fd 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -44,13 +44,17 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "bmap.h" #include "glock.h" #include "glops.h" #include "log.h" +#include "lvb.h" #include "meta_io.h" #include "quota.h" #include "rgrp.h" @@ -59,6 +63,7 @@ #include "inode.h" #include "ops_file.h" #include "ops_address.h" +#include "util.h" #define QUOTA_USER 1 #define QUOTA_GROUP 0 @@ -244,7 +249,7 @@ static void slot_put(struct gfs2_quota_data *qd) static int bh_get(struct gfs2_quota_data *qd) { struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; - struct gfs2_inode *ip = get_v2ip(sdp->sd_qc_inode); + struct gfs2_inode *ip = sdp->sd_qc_inode->u.generic_ip; unsigned int block, offset; uint64_t dblock; int new = 0; @@ -526,7 +531,7 @@ static int sort_qd(const void *a, const void *b) static void do_qc(struct gfs2_quota_data *qd, int64_t change) { struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; - struct gfs2_inode *ip = get_v2ip(sdp->sd_qc_inode); + struct gfs2_inode *ip = sdp->sd_qc_inode->u.generic_ip; struct gfs2_quota_change *qc = qd->qd_bh_qc; int64_t x; @@ -642,7 +647,7 @@ unlock: static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) { struct gfs2_sbd *sdp = (*qda)->qd_gl->gl_sbd; - struct gfs2_inode *ip = get_v2ip(sdp->sd_quota_inode); + struct gfs2_inode *ip = sdp->sd_quota_inode->u.generic_ip; unsigned int data_blocks, ind_blocks; struct file_ra_state ra_state; struct gfs2_holder *ghs, i_gh; @@ -753,6 +758,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, struct gfs2_holder *q_gh) { struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; + struct gfs2_inode *ip = sdp->sd_quota_inode->u.generic_ip; struct gfs2_holder i_gh; struct gfs2_quota q; char buf[sizeof(struct gfs2_quota)]; @@ -776,7 +782,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, if (error) return error; - error = gfs2_glock_nq_init(get_v2ip(sdp->sd_quota_inode)->i_gl, + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh); if (error) @@ -784,7 +790,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, memset(buf, 0, sizeof(struct gfs2_quota)); pos = qd2offset(qd); - error = gfs2_internal_read(get_v2ip(sdp->sd_quota_inode), + error = gfs2_internal_read(ip, &ra_state, buf, &pos, sizeof(struct gfs2_quota)); @@ -1118,7 +1124,7 @@ int gfs2_quota_read(struct gfs2_sbd *sdp, int user, uint32_t id, int gfs2_quota_init(struct gfs2_sbd *sdp) { - struct gfs2_inode *ip = get_v2ip(sdp->sd_qc_inode); + struct gfs2_inode *ip = sdp->sd_qc_inode->u.generic_ip; unsigned int blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; unsigned int x, slot = 0; unsigned int found = 0; @@ -1133,7 +1139,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp) return -EIO; } sdp->sd_quota_slots = blocks * sdp->sd_qc_per_block; - sdp->sd_quota_chunks = DIV_RU(sdp->sd_quota_slots, 8 * PAGE_SIZE); + sdp->sd_quota_chunks = DIV_ROUND_UP(sdp->sd_quota_slots, 8 * PAGE_SIZE); error = -ENOMEM; diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index e5f2b284fa54eb..2df450e2f433eb 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -12,9 +12,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "bmap.h" #include "glock.h" #include "glops.h" @@ -23,22 +26,24 @@ #include "meta_io.h" #include "recovery.h" #include "super.h" +#include "util.h" int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk, struct buffer_head **bh) { - struct gfs2_glock *gl = get_v2ip(jd->jd_inode)->i_gl; + struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; + struct gfs2_glock *gl = ip->i_gl; int new = 0; uint64_t dblock; uint32_t extlen; int error; - error = gfs2_block_map(get_v2ip(jd->jd_inode), blk, &new, &dblock, + error = gfs2_block_map(ip, blk, &new, &dblock, &extlen); if (error) return error; if (!dblock) { - gfs2_consist_inode(get_v2ip(jd->jd_inode)); + gfs2_consist_inode(ip); return -EIO; } @@ -185,7 +190,7 @@ static int find_good_lh(struct gfs2_jdesc *jd, unsigned int *blk, *blk = 0; if (*blk == orig_blk) { - gfs2_consist_inode(get_v2ip(jd->jd_inode)); + gfs2_consist_inode(jd->jd_inode->u.generic_ip); return -EIO; } } @@ -219,7 +224,7 @@ static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head) continue; if (lh.lh_sequence == head->lh_sequence) { - gfs2_consist_inode(get_v2ip(jd->jd_inode)); + gfs2_consist_inode(jd->jd_inode->u.generic_ip); return -EIO; } if (lh.lh_sequence < head->lh_sequence) @@ -295,7 +300,8 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header *head) static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start, unsigned int end, int pass) { - struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd; + struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; + struct gfs2_sbd *sdp = ip->i_sbd; struct buffer_head *bh; struct gfs2_log_descriptor *ld; int error = 0; @@ -324,7 +330,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start, continue; } if (error == 1) { - gfs2_consist_inode(get_v2ip(jd->jd_inode)); + gfs2_consist_inode(jd->jd_inode->u.generic_ip); error = -EIO; } brelse(bh); @@ -361,7 +367,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start, static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head) { - struct gfs2_inode *ip = get_v2ip(jd->jd_inode); + struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; struct gfs2_sbd *sdp = ip->i_sbd; unsigned int lblock; int new = 0; @@ -420,7 +426,8 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head) int gfs2_recover_journal(struct gfs2_jdesc *jd, int wait) { - struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd; + struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; + struct gfs2_sbd *sdp = ip->i_sbd; struct gfs2_log_header head; struct gfs2_holder j_gh, ji_gh, t_gh; unsigned long t; @@ -450,7 +457,7 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd, int wait) goto fail; }; - error = gfs2_glock_nq_init(get_v2ip(jd->jd_inode)->i_gl, LM_ST_SHARED, + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_NOEXP, &ji_gh); if (error) goto fail_gunlock_j; @@ -516,7 +523,7 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd, int wait) gfs2_glock_dq_uninit(&t_gh); - t = DIV_RU(jiffies - t, HZ); + t = DIV_ROUND_UP(jiffies - t, HZ); fs_info(sdp, "jid=%u: Journal replayed in %lus\n", jd->jd_jid, t); diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 9525b176f50280..4ae55969439693 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -13,9 +13,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "bits.h" #include "glock.h" #include "glops.h" @@ -26,6 +29,7 @@ #include "super.h" #include "trans.h" #include "ops_file.h" +#include "util.h" /** * gfs2_rgrp_verify - Verify that a resource group is consistent @@ -171,7 +175,7 @@ static void clear_rgrpdi(struct gfs2_sbd *sdp) list_del(&rgd->rd_list_mru); if (gl) { - set_gl2rgd(gl, NULL); + gl->gl_object = NULL; gfs2_glock_put(gl); } @@ -320,7 +324,7 @@ static int gfs2_ri_update(struct gfs2_inode *ip) if (error) goto fail; - set_gl2rgd(rgd->rd_gl, rgd); + rgd->rd_gl->gl_object = rgd; rgd->rd_rg_vn = rgd->rd_gl->gl_vn - 1; } @@ -354,7 +358,7 @@ static int gfs2_ri_update(struct gfs2_inode *ip) int gfs2_rindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ri_gh) { - struct gfs2_inode *ip = get_v2ip(sdp->sd_rindex); + struct gfs2_inode *ip = sdp->sd_rindex->u.generic_ip; struct gfs2_glock *gl = ip->i_gl; int error; diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 2c1c6aa1c077e8..9ccf0b9c5980df 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -12,9 +12,12 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "bmap.h" #include "dir.h" #include "format.h" @@ -29,6 +32,7 @@ #include "super.h" #include "trans.h" #include "unlinked.h" +#include "util.h" /** * gfs2_tune_init - Fill a gfs2_tune structure with default values @@ -207,12 +211,12 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) /* Compute maximum reservation required to add a entry to a directory */ - hash_blocks = DIV_RU(sizeof(uint64_t) * (1 << GFS2_DIR_MAX_DEPTH), + hash_blocks = DIV_ROUND_UP(sizeof(uint64_t) * (1 << GFS2_DIR_MAX_DEPTH), sdp->sd_jbsize); ind_blocks = 0; for (tmp_blocks = hash_blocks; tmp_blocks > sdp->sd_diptrs;) { - tmp_blocks = DIV_RU(tmp_blocks, sdp->sd_inptrs); + tmp_blocks = DIV_ROUND_UP(tmp_blocks, sdp->sd_inptrs); ind_blocks += tmp_blocks; } @@ -278,7 +282,7 @@ int gfs2_do_upgrade(struct gfs2_sbd *sdp, struct gfs2_glock *sb_gl) int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh) { - struct gfs2_inode *dip = get_v2ip(sdp->sd_jindex); + struct gfs2_inode *dip = sdp->sd_jindex->u.generic_ip; struct qstr name; char buf[20]; struct gfs2_jdesc *jd; @@ -296,7 +300,7 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh) name.len = sprintf(buf, "journal%u", sdp->sd_journals); - error = gfs2_dir_search(get_v2ip(sdp->sd_jindex), + error = gfs2_dir_search(sdp->sd_jindex->u.generic_ip, &name, NULL, NULL); if (error == -ENOENT) { error = 0; @@ -419,7 +423,7 @@ struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp) int gfs2_jdesc_check(struct gfs2_jdesc *jd) { - struct gfs2_inode *ip = get_v2ip(jd->jd_inode); + struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; struct gfs2_sbd *sdp = ip->i_sbd; int ar; int error; @@ -471,7 +475,8 @@ int gfs2_lookup_master_dir(struct gfs2_sbd *sdp) int gfs2_make_fs_rw(struct gfs2_sbd *sdp) { - struct gfs2_glock *j_gl = get_v2ip(sdp->sd_jdesc->jd_inode)->i_gl; + struct gfs2_inode *ip = sdp->sd_jdesc->jd_inode->u.generic_ip; + struct gfs2_glock *j_gl = ip->i_gl; struct gfs2_holder t_gh; struct gfs2_log_header head; int error; @@ -481,7 +486,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp) if (error) return error; - gfs2_meta_cache_flush(get_v2ip(sdp->sd_jdesc->jd_inode)); + gfs2_meta_cache_flush(ip); j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA); error = gfs2_find_jhead(sdp->sd_jdesc, &head); @@ -559,9 +564,9 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp) int gfs2_statfs_init(struct gfs2_sbd *sdp) { - struct gfs2_inode *m_ip = get_v2ip(sdp->sd_statfs_inode); + struct gfs2_inode *m_ip = sdp->sd_statfs_inode->u.generic_ip; struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master; - struct gfs2_inode *l_ip = get_v2ip(sdp->sd_sc_inode); + struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip; struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; struct buffer_head *m_bh, *l_bh; struct gfs2_holder gh; @@ -608,7 +613,7 @@ int gfs2_statfs_init(struct gfs2_sbd *sdp) void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free, int64_t dinodes) { - struct gfs2_inode *l_ip = get_v2ip(sdp->sd_sc_inode); + struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip; struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; struct buffer_head *l_bh; int error; @@ -634,8 +639,8 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free, int gfs2_statfs_sync(struct gfs2_sbd *sdp) { - struct gfs2_inode *m_ip = get_v2ip(sdp->sd_statfs_inode); - struct gfs2_inode *l_ip = get_v2ip(sdp->sd_sc_inode); + struct gfs2_inode *m_ip = sdp->sd_statfs_inode->u.generic_ip; + struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip; struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master; struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; struct gfs2_holder gh; @@ -795,7 +800,8 @@ int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc) error = err; } else { if (!error) - error = statfs_slow_fill(get_gl2rgd(gh->gh_gl), sc); + error = statfs_slow_fill( + gh->gh_gl->gl_object, sc); gfs2_glock_dq_uninit(gh); } } @@ -846,6 +852,7 @@ struct lfcc { int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, struct gfs2_holder *t_gh) { + struct gfs2_inode *ip; struct gfs2_holder ji_gh; struct gfs2_jdesc *jd; struct lfcc *lfcc; @@ -863,7 +870,8 @@ int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, struct gfs2_holder *t_gh) error = -ENOMEM; goto out; } - error = gfs2_glock_nq_init(get_v2ip(jd->jd_inode)->i_gl, + ip = jd->jd_inode->u.generic_ip; + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &lfcc->gh); if (error) { diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index f87df8ec041ea1..f05ba8f6913285 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c @@ -14,15 +14,19 @@ #include #include #include +#include #include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "lm.h" #include "sys.h" #include "super.h" #include "glock.h" #include "quota.h" +#include "util.h" char *gfs2_sys_margs; spinlock_t gfs2_sys_margs_lock; diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index 0a0ea70eac4c69..2cce68aec134ff 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -12,14 +12,18 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "glock.h" #include "log.h" #include "lops.h" #include "meta_io.h" #include "trans.h" +#include "util.h" int gfs2_trans_begin_i(struct gfs2_sbd *sdp, unsigned int blocks, unsigned int revokes, char *file, unsigned int line) @@ -27,7 +31,7 @@ int gfs2_trans_begin_i(struct gfs2_sbd *sdp, unsigned int blocks, struct gfs2_trans *tr; int error; - if (gfs2_assert_warn(sdp, !get_transaction) || + if (gfs2_assert_warn(sdp, !current->journal_info) || gfs2_assert_warn(sdp, blocks || revokes)) { fs_warn(sdp, "(%s, %u)\n", file, line); return -EINVAL; @@ -69,7 +73,7 @@ int gfs2_trans_begin_i(struct gfs2_sbd *sdp, unsigned int blocks, if (error) goto fail_gunlock; - set_transaction(tr); + current->journal_info = tr; return 0; @@ -90,8 +94,8 @@ void gfs2_trans_end(struct gfs2_sbd *sdp) struct gfs2_trans *tr; struct gfs2_holder *t_gh; - tr = get_transaction; - set_transaction(NULL); + tr = current->journal_info; + current->journal_info = NULL; if (gfs2_assert_warn(sdp, tr)) return; @@ -147,12 +151,12 @@ void gfs2_trans_add_bh(struct gfs2_glock *gl, struct buffer_head *bh, int meta) struct gfs2_sbd *sdp = gl->gl_sbd; struct gfs2_bufdata *bd; - bd = get_v2bd(bh); + bd = bh->b_private; if (bd) gfs2_assert(sdp, bd->bd_gl == gl); else { gfs2_attach_bufdata(gl, bh, meta); - bd = get_v2bd(bh); + bd = bh->b_private; } lops_add(sdp, &bd->bd_le); } @@ -186,8 +190,9 @@ void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, uint64_t blkno) gfs2_log_unlock(sdp); if (found) { + struct gfs2_trans *tr = current->journal_info; kfree(rv); - get_transaction->tr_num_revoke_rm++; + tr->tr_num_revoke_rm++; } } diff --git a/fs/gfs2/unlinked.c b/fs/gfs2/unlinked.c index e92a3a11815ba8..24b91c23bc2dc6 100644 --- a/fs/gfs2/unlinked.c +++ b/fs/gfs2/unlinked.c @@ -13,19 +13,23 @@ #include #include #include +#include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "bmap.h" #include "inode.h" #include "meta_io.h" #include "trans.h" #include "unlinked.h" +#include "util.h" static int munge_ondisk(struct gfs2_sbd *sdp, unsigned int slot, struct gfs2_unlinked_tag *ut) { - struct gfs2_inode *ip = get_v2ip(sdp->sd_ut_inode); + struct gfs2_inode *ip = sdp->sd_ut_inode->u.generic_ip; unsigned int block, offset; uint64_t dblock; int new = 0; @@ -312,7 +316,7 @@ int gfs2_unlinked_dealloc(struct gfs2_sbd *sdp) int gfs2_unlinked_init(struct gfs2_sbd *sdp) { - struct gfs2_inode *ip = get_v2ip(sdp->sd_ut_inode); + struct gfs2_inode *ip = sdp->sd_ut_inode->u.generic_ip; unsigned int blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; unsigned int x, slot = 0; unsigned int found = 0; @@ -327,7 +331,8 @@ int gfs2_unlinked_init(struct gfs2_sbd *sdp) return -EIO; } sdp->sd_unlinked_slots = blocks * sdp->sd_ut_per_block; - sdp->sd_unlinked_chunks = DIV_RU(sdp->sd_unlinked_slots, 8 * PAGE_SIZE); + sdp->sd_unlinked_chunks = DIV_ROUND_UP(sdp->sd_unlinked_slots, + 8 * PAGE_SIZE); error = -ENOMEM; diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c index 4fb1704aac10d8..8b22fa91bd149d 100644 --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c @@ -13,12 +13,16 @@ #include #include #include +#include #include #include #include "gfs2.h" +#include "lm_interface.h" +#include "incore.h" #include "glock.h" #include "lm.h" +#include "util.h" kmem_cache_t *gfs2_glock_cachep __read_mostly; kmem_cache_t *gfs2_inode_cachep __read_mostly; diff --git a/include/linux/gfs2_ondisk.h b/include/linux/gfs2_ondisk.h index ec432e0c208df3..8d4f0445df474c 100644 --- a/include/linux/gfs2_ondisk.h +++ b/include/linux/gfs2_ondisk.h @@ -50,15 +50,18 @@ * An on-disk inode number */ -#define gfs2_inum_equal(ino1, ino2) \ - (((ino1)->no_formal_ino == (ino2)->no_formal_ino) && \ - ((ino1)->no_addr == (ino2)->no_addr)) - struct gfs2_inum { __be64 no_formal_ino; __be64 no_addr; }; +static inline int gfs2_inum_equal(const struct gfs2_inum *ino1, + const struct gfs2_inum *ino2) +{ + return ino1->no_formal_ino == ino2->no_formal_ino && + ino1->no_addr == ino2->no_addr; +} + /* * Generic metadata head structure * Every inplace buffer logged in the journal must start with this. diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 3b507bf05d0983..f789278a625aeb 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -29,6 +29,7 @@ extern const char linux_banner[]; #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define ALIGN(x,a) (((x)+(a)-1)&~((a)-1)) +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) #define KERN_EMERG "<0>" /* system is unusable */ #define KERN_ALERT "<1>" /* action must be taken immediately */ -- cgit 1.2.3-korg From d0dc80dbafb5c10ad2084831a61bbf945484a139 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 29 Mar 2006 14:36:49 -0500 Subject: [GFS2] Update debugging code Update the debugging code in trans.c and at the same time improve the debugging code for gfs2_holders. The new code should be pretty fast during the normal case and provide just as much information in case of errors (or more). One small function from glock.c has moved to glock.h as a static inline so that its return address won't get in the way of the debugging. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 34 +++++++++------------------------- fs/gfs2/glock.h | 27 +++++++++++++++++++++++++-- fs/gfs2/incore.h | 4 ++-- fs/gfs2/trans.c | 32 ++++++++++++++------------------ fs/gfs2/trans.h | 8 ++------ 5 files changed, 52 insertions(+), 53 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 81b06812b32967..6a1b42cf4df409 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -357,6 +358,7 @@ void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, int flags, { INIT_LIST_HEAD(&gh->gh_list); gh->gh_gl = gl; + gh->gh_ip = (unsigned long)__builtin_return_address(0); gh->gh_owner = (flags & GL_NEVER_RECURSE) ? NULL : current; gh->gh_state = state; gh->gh_flags = flags; @@ -388,6 +390,7 @@ void gfs2_holder_reinit(unsigned int state, int flags, struct gfs2_holder *gh) gh->gh_flags |= GL_LOCAL_EXCL; gh->gh_iflags &= 1 << HIF_ALLOCED; + gh->gh_ip = (unsigned long)__builtin_return_address(0); } /** @@ -400,6 +403,7 @@ void gfs2_holder_uninit(struct gfs2_holder *gh) { gfs2_glock_put(gh->gh_gl); gh->gh_gl = NULL; + gh->gh_ip = 0; } /** @@ -427,7 +431,7 @@ struct gfs2_holder *gfs2_holder_get(struct gfs2_glock *gl, unsigned int state, gfs2_holder_init(gl, state, flags, gh); set_bit(HIF_ALLOCED, &gh->gh_iflags); - + gh->gh_ip = (unsigned long)__builtin_return_address(0); return gh; } @@ -1238,6 +1242,9 @@ static int recurse_check(struct gfs2_holder *existing, struct gfs2_holder *new, return 0; fail: + print_symbol(KERN_WARNING "GFS2: Existing holder from %s\n", + existing->gh_ip); + print_symbol(KERN_WARNING "GFS2: New holder from %s\n", new->gh_ip); set_bit(HIF_ABORTED, &new->gh_iflags); return -EINVAL; } @@ -1543,30 +1550,6 @@ int gfs2_glock_be_greedy(struct gfs2_glock *gl, unsigned int time) return 0; } -/** - * gfs2_glock_nq_init - intialize a holder and enqueue it on a glock - * @gl: the glock - * @state: the state we're requesting - * @flags: the modifier flags - * @gh: the holder structure - * - * Returns: 0, GLR_*, or errno - */ - -int gfs2_glock_nq_init(struct gfs2_glock *gl, unsigned int state, int flags, - struct gfs2_holder *gh) -{ - int error; - - gfs2_holder_init(gl, state, flags, gh); - - error = gfs2_glock_nq(gh); - if (error) - gfs2_holder_uninit(gh); - - return error; -} - /** * gfs2_glock_dq_uninit - dequeue a holder from a glock and initialize it * @gh: the holder structure @@ -2334,6 +2317,7 @@ static int dump_holder(char *str, struct gfs2_holder *gh) if (test_bit(x, &gh->gh_iflags)) printk(" %u", x); printk(" \n"); + print_symbol(KERN_INFO " initialized at: %s\n", gh->gh_ip); error = 0; diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 06847ebebdee5f..560029de8d0782 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -106,8 +106,6 @@ void gfs2_glock_force_drop(struct gfs2_glock *gl); int gfs2_glock_be_greedy(struct gfs2_glock *gl, unsigned int time); -int gfs2_glock_nq_init(struct gfs2_glock *gl, unsigned int state, int flags, - struct gfs2_holder *gh); void gfs2_glock_dq_uninit(struct gfs2_holder *gh); int gfs2_glock_nq_num(struct gfs2_sbd *sdp, uint64_t number, struct gfs2_glock_operations *glops, @@ -121,6 +119,31 @@ void gfs2_glock_prefetch_num(struct gfs2_sbd *sdp, uint64_t number, struct gfs2_glock_operations *glops, unsigned int state, int flags); +/** + * gfs2_glock_nq_init - intialize a holder and enqueue it on a glock + * @gl: the glock + * @state: the state we're requesting + * @flags: the modifier flags + * @gh: the holder structure + * + * Returns: 0, GLR_*, or errno + */ + +static inline int gfs2_glock_nq_init(struct gfs2_glock *gl, + unsigned int state, int flags, + struct gfs2_holder *gh) +{ + int error; + + gfs2_holder_init(gl, state, flags, gh); + + error = gfs2_glock_nq(gh); + if (error) + gfs2_holder_uninit(gh); + + return error; +} + /* Lock Value Block functions */ int gfs2_lvb_hold(struct gfs2_glock *gl); diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 35163b5624607b..b5a994d1b5f7fd 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -161,6 +161,7 @@ struct gfs2_holder { int gh_error; unsigned long gh_iflags; struct completion gh_wait; + unsigned long gh_ip; }; enum { @@ -353,8 +354,7 @@ struct gfs2_log_buf { }; struct gfs2_trans { - char *tr_file; - unsigned int tr_line; + unsigned long tr_ip; unsigned int tr_blocks; unsigned int tr_revokes; diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index aa1a619f085405..3fae3d4e9ae4ac 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "gfs2.h" @@ -25,24 +26,20 @@ #include "trans.h" #include "util.h" -int gfs2_trans_begin_i(struct gfs2_sbd *sdp, unsigned int blocks, - unsigned int revokes, char *file, unsigned int line) +int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks, + unsigned int revokes) { struct gfs2_trans *tr; int error; - if (gfs2_assert_warn(sdp, !current->journal_info) || - gfs2_assert_warn(sdp, blocks || revokes)) { - fs_warn(sdp, "(%s, %u)\n", file, line); - return -EINVAL; - } + BUG_ON(current->journal_info); + BUG_ON(blocks == 0 && revokes == 0); tr = kzalloc(sizeof(struct gfs2_trans), GFP_NOFS); if (!tr) return -ENOMEM; - tr->tr_file = file; - tr->tr_line = line; + tr->tr_ip = (unsigned long)__builtin_return_address(0); tr->tr_blocks = blocks; tr->tr_revokes = revokes; tr->tr_reserved = 1; @@ -104,16 +101,15 @@ void gfs2_trans_end(struct gfs2_sbd *sdp) return; } - if (gfs2_assert_withdraw(sdp, tr->tr_num_buf <= tr->tr_blocks)) - fs_err(sdp, "tr_num_buf = %u, tr_blocks = %u " - "tr_file = %s, tr_line = %u\n", - tr->tr_num_buf, tr->tr_blocks, - tr->tr_file, tr->tr_line); + if (gfs2_assert_withdraw(sdp, tr->tr_num_buf <= tr->tr_blocks)) { + fs_err(sdp, "tr_num_buf = %u, tr_blocks = %u ", + tr->tr_num_buf, tr->tr_blocks); + print_symbol(KERN_WARNING "GFS2: Transaction created at: %s\n", tr->tr_ip); + } if (gfs2_assert_withdraw(sdp, tr->tr_num_revoke <= tr->tr_revokes)) - fs_err(sdp, "tr_num_revoke = %u, tr_revokes = %u " - "tr_file = %s, tr_line = %u\n", - tr->tr_num_revoke, tr->tr_revokes, - tr->tr_file, tr->tr_line); + fs_err(sdp, "tr_num_revoke = %u, tr_revokes = %u ", + tr->tr_num_revoke, tr->tr_revokes); + print_symbol(KERN_WARNING "GFS2: Transaction created at: %s\n", tr->tr_ip); gfs2_log_commit(sdp, tr); diff --git a/fs/gfs2/trans.h b/fs/gfs2/trans.h index f7f3e2a3d5905d..6b5e9e8bf56192 100644 --- a/fs/gfs2/trans.h +++ b/fs/gfs2/trans.h @@ -21,12 +21,8 @@ #define RES_STATFS 1 #define RES_QUOTA 2 -#define gfs2_trans_begin(sdp, blocks, revokes) \ -gfs2_trans_begin_i((sdp), (blocks), (revokes), __FILE__, __LINE__) - -int gfs2_trans_begin_i(struct gfs2_sbd *sdp, - unsigned int blocks, unsigned int revokes, - char *file, unsigned int line); +int gfs2_trans_begin(struct gfs2_sbd *sdp, + unsigned int blocks, unsigned int revokes); void gfs2_trans_end(struct gfs2_sbd *sdp); -- cgit 1.2.3-korg From fe1bdedc6c16adedc6fd3636185ea91596b1d6eb Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Tue, 18 Apr 2006 10:09:15 -0400 Subject: [GFS2] Use vmalloc() in dir code When allocating memory to sort directory entries, use vmalloc() rather than kmalloc() since for larger directories, the required size can easily be graeter than the 128k maximum of kmalloc(). Also adding the first steps towards getting the AOP_TRUNCATED_PAGE return code get in the glock code by flagging all places where we request a glock and we are holding a page lock. Signed-off-by: Steven Whitehouse --- fs/gfs2/dir.c | 5 +++-- fs/gfs2/glock.c | 3 +++ fs/gfs2/glock.h | 1 + fs/gfs2/incore.h | 2 +- fs/gfs2/meta_io.c | 2 +- fs/gfs2/ops_address.c | 4 ++-- fs/gfs2/ops_inode.c | 3 +-- fs/gfs2/ops_super.c | 2 -- 8 files changed, 12 insertions(+), 10 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index fe6c5adc5df02e..eb68cdd41d4817 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -61,6 +61,7 @@ #include #include #include +#include #include #include "gfs2.h" @@ -1290,7 +1291,7 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque, return 0; error = -ENOMEM; - larr = kmalloc((leaves + entries) * sizeof(void*), GFP_KERNEL); + larr = vmalloc((leaves + entries) * sizeof(void*)); if (!larr) goto out; darr = (const struct gfs2_dirent **)(larr + leaves); @@ -1323,7 +1324,7 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque, out_kfree: for(i = 0; i < leaf; i++) brelse(larr[i]); - kfree(larr); + vfree(larr); out: return error; } diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 6a1b42cf4df409..4ed13787b7ec3f 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -461,6 +461,9 @@ static void handle_recurse(struct gfs2_holder *gh) struct gfs2_holder *tmp_gh, *safe; int found = 0; + printk(KERN_INFO "recursion %016llx, %u\n", gl->gl_name.ln_number, + gl->gl_name.ln_type); + if (gfs2_assert_warn(sdp, gh->gh_owner)) return; diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 560029de8d0782..b6646e7fed153b 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -27,6 +27,7 @@ #define GL_SYNC 0x00000800 #define GL_NOCANCEL 0x00001000 #define GL_NEVER_RECURSE 0x00002000 +#define GL_AOP 0x00004000 #define GLR_TRYFAILED 13 #define GLR_CANCELED 14 diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index dfed83b37ab70d..761f00153d43b6 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -156,7 +156,7 @@ struct gfs2_holder { struct gfs2_glock *gh_gl; struct task_struct *gh_owner; unsigned int gh_state; - int gh_flags; + unsigned gh_flags; int gh_error; unsigned long gh_iflags; diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 4a6aacf294d5a3..74cf28e77b4724 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -881,7 +881,7 @@ void gfs2_meta_syncfs(struct gfs2_sbd *sdp) gfs2_ail1_start(sdp, DIO_ALL); if (gfs2_ail1_empty(sdp, DIO_ALL)) break; - msleep(100); + msleep(10); } } diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 3fd8c6ec256cc4..005c2522a879b4 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -216,7 +216,7 @@ static int gfs2_readpage(struct file *file, struct page *page) int error; if (file != &gfs2_internal_file_sentinal) { - gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh); + gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|GL_AOP, &gh); error = gfs2_glock_nq_m_atime(1, &gh); if (error) goto out_unlock; @@ -267,7 +267,7 @@ static int gfs2_prepare_write(struct file *file, struct page *page, loff_t end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; struct gfs2_alloc *al; - gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME, &ip->i_gh); + gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|GL_AOP, &ip->i_gh); error = gfs2_glock_nq_m_atime(1, &ip->i_gh); if (error) goto out_uninit; diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 1e2b709711aed7..62a12a59d91b6c 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -742,8 +742,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, if (error) goto out_gunlock_q; - error = gfs2_trans_begin(sdp, - sdp->sd_max_dirres + + error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + al->al_rgd->rd_ri.ri_length + 4 * RES_DINODE + 4 * RES_LEAF + RES_UNLINKED + RES_STATFS + diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 80ce40c1dfb618..60bf2563c7b4a4 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -132,9 +132,7 @@ static void gfs2_put_super(struct super_block *sb) /* At this point, we're through participating in the lockspace */ gfs2_sys_fs_del(sdp); - vfree(sdp); - sb->s_fs_info = NULL; } -- cgit 1.2.3-korg From 190562bd84a484bf6590425aa2bb4d6d611c112b Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Thu, 20 Apr 2006 16:57:23 -0400 Subject: [GFS2] Fix a bug: scheduling under a spinlock At some stage, a mutex was added to gfs2_glock_put() without checking all its call sites. Two of them were called from under a spinlock causing random delays at various points and crashes. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 30 ++++++++++++++++++++---------- fs/gfs2/glock.h | 6 +++--- fs/gfs2/inode.c | 2 +- fs/gfs2/log.c | 1 + fs/gfs2/meta_io.c | 2 ++ 5 files changed, 27 insertions(+), 14 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 4ed13787b7ec3f..32cc4005307d1b 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -158,6 +158,7 @@ int gfs2_glock_put(struct gfs2_glock *gl) if (kref_put(&gl->gl_ref, kill_glock)) { list_del_init(&gl->gl_list); write_unlock(&bucket->hb_lock); + BUG_ON(spin_is_locked(&gl->gl_spin)); glock_free(gl); rv = 1; goto out; @@ -353,13 +354,14 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, * */ -void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, int flags, +void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, unsigned flags, struct gfs2_holder *gh) { + flags |= GL_NEVER_RECURSE; INIT_LIST_HEAD(&gh->gh_list); gh->gh_gl = gl; gh->gh_ip = (unsigned long)__builtin_return_address(0); - gh->gh_owner = (flags & GL_NEVER_RECURSE) ? NULL : current; + gh->gh_owner = current; gh->gh_state = state; gh->gh_flags = flags; gh->gh_error = 0; @@ -382,10 +384,10 @@ void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, int flags, * */ -void gfs2_holder_reinit(unsigned int state, int flags, struct gfs2_holder *gh) +void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *gh) { gh->gh_state = state; - gh->gh_flags = flags; + gh->gh_flags = flags | GL_NEVER_RECURSE; if (gh->gh_state == LM_ST_EXCLUSIVE) gh->gh_flags |= GL_LOCAL_EXCL; @@ -461,6 +463,8 @@ static void handle_recurse(struct gfs2_holder *gh) struct gfs2_holder *tmp_gh, *safe; int found = 0; + BUG_ON(!spin_is_locked(&gl->gl_spin)); + printk(KERN_INFO "recursion %016llx, %u\n", gl->gl_name.ln_number, gl->gl_name.ln_type); @@ -502,6 +506,8 @@ static void do_unrecurse(struct gfs2_holder *gh) struct gfs2_holder *tmp_gh, *last_gh = NULL; int found = 0; + BUG_ON(!spin_is_locked(&gl->gl_spin)); + if (gfs2_assert_warn(sdp, gh->gh_owner)) return; @@ -676,7 +682,6 @@ static int rq_greedy(struct gfs2_holder *gh) * @gl: the glock * */ - static void run_queue(struct gfs2_glock *gl) { struct gfs2_holder *gh; @@ -779,6 +784,7 @@ void gfs2_glmutex_unlock(struct gfs2_glock *gl) spin_lock(&gl->gl_spin); clear_bit(GLF_LOCK, &gl->gl_flags); run_queue(gl); + BUG_ON(!spin_is_locked(&gl->gl_spin)); spin_unlock(&gl->gl_spin); } @@ -1244,7 +1250,7 @@ static int recurse_check(struct gfs2_holder *existing, struct gfs2_holder *new, return 0; - fail: +fail: print_symbol(KERN_WARNING "GFS2: Existing holder from %s\n", existing->gh_ip); print_symbol(KERN_WARNING "GFS2: New holder from %s\n", new->gh_ip); @@ -1263,6 +1269,8 @@ static void add_to_queue(struct gfs2_holder *gh) struct gfs2_glock *gl = gh->gh_gl; struct gfs2_holder *existing; + BUG_ON(!gh->gh_owner); + if (!gh->gh_owner) goto out; @@ -1331,7 +1339,7 @@ int gfs2_glock_nq(struct gfs2_holder *gh) if (!(gh->gh_flags & GL_ASYNC)) { error = glock_wait_internal(gh); if (error == GLR_CANCELED) { - msleep(1000); + msleep(100); goto restart; } } @@ -1360,7 +1368,7 @@ int gfs2_glock_poll(struct gfs2_holder *gh) else if (list_empty(&gh->gh_list)) { if (gh->gh_error == GLR_CANCELED) { spin_unlock(&gl->gl_spin); - msleep(1000); + msleep(100); if (gfs2_glock_nq(gh)) return 1; return 0; @@ -1386,7 +1394,7 @@ int gfs2_glock_wait(struct gfs2_holder *gh) error = glock_wait_internal(gh); if (error == GLR_CANCELED) { - msleep(1000); + msleep(100); gh->gh_flags &= ~GL_ASYNC; error = gfs2_glock_nq(gh); } @@ -2217,10 +2225,12 @@ static void clear_glock(struct gfs2_glock *gl) if (!list_empty(&gl->gl_reclaim)) { list_del_init(&gl->gl_reclaim); atomic_dec(&sdp->sd_reclaim_count); + spin_unlock(&sdp->sd_reclaim_lock); released = gfs2_glock_put(gl); gfs2_assert(sdp, !released); + } else { + spin_unlock(&sdp->sd_reclaim_lock); } - spin_unlock(&sdp->sd_reclaim_lock); if (gfs2_glmutex_trylock(gl)) { if (gl->gl_ops == &gfs2_inode_glops) { diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index b6646e7fed153b..ed5bc3e65397f1 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -81,10 +81,10 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, int create, struct gfs2_glock **glp); void gfs2_glock_hold(struct gfs2_glock *gl); int gfs2_glock_put(struct gfs2_glock *gl); - -void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, int flags, +void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, unsigned flags, struct gfs2_holder *gh); -void gfs2_holder_reinit(unsigned int state, int flags, struct gfs2_holder *gh); +void gfs2_holder_reinit(unsigned int state, unsigned flags, + struct gfs2_holder *gh); void gfs2_holder_uninit(struct gfs2_holder *gh); struct gfs2_holder *gfs2_holder_get(struct gfs2_glock *gl, unsigned int state, int flags, gfp_t gfp_flags); diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 6140c2434e8500..fb5a4d06e926b5 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -409,8 +409,8 @@ void gfs2_inode_destroy(struct gfs2_inode *ip) spin_lock(&io_gl->gl_spin); io_gl->gl_object = NULL; - gfs2_glock_put(i_gl); spin_unlock(&io_gl->gl_spin); + gfs2_glock_put(i_gl); gfs2_glock_dq_uninit(&ip->i_iopen_gh); diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index b0dd0b9ad79bae..9e32e0faaf20ae 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -578,6 +578,7 @@ void gfs2_log_shutdown(struct gfs2_sbd *sdp) gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke); gfs2_assert_withdraw(sdp, !sdp->sd_log_num_rg); gfs2_assert_withdraw(sdp, !sdp->sd_log_num_databuf); + gfs2_assert_withdraw(sdp, !sdp->sd_log_num_hdrs); gfs2_assert_withdraw(sdp, list_empty(&sdp->sd_ail1_list)); sdp->sd_log_flush_head = sdp->sd_log_head; diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 74cf28e77b4724..da49973a90d111 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -214,6 +214,8 @@ void gfs2_ail1_start_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai) struct buffer_head *bh; int retry; + BUG_ON(!spin_is_locked(&sdp->sd_log_lock)); + do { retry = 0; -- cgit 1.2.3-korg From 5965b1f4792a1a9364b4e1ed6be8778a50eb981b Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 26 Apr 2006 13:21:55 -0400 Subject: [GFS2] Don't do recursive locking in glock layer This patch changes the last user of recursive locking so that it no longer needs this feature and removes it from the glock layer. This makes the glock code a lot simpler and easier to understand. Its also a prerequsite to adding support for the AOP_TRUNCATED_PAGE return code (or at least it is if you don't want your brain to melt in the process) I've left in a couple of checks just in case there is some place else in the code which is still using this feature that I didn't spot yet, but they can probably be removed long term. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 162 ++--------------------------------------------------- fs/gfs2/incore.h | 1 - fs/gfs2/recovery.c | 79 +++++++++++++------------- 3 files changed, 46 insertions(+), 196 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 32cc4005307d1b..0f317155915d14 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -449,86 +449,6 @@ void gfs2_holder_put(struct gfs2_holder *gh) kfree(gh); } -/** - * handle_recurse - put other holder structures (marked recursive) - * into the holders list - * @gh: the holder structure - * - */ - -static void handle_recurse(struct gfs2_holder *gh) -{ - struct gfs2_glock *gl = gh->gh_gl; - struct gfs2_sbd *sdp = gl->gl_sbd; - struct gfs2_holder *tmp_gh, *safe; - int found = 0; - - BUG_ON(!spin_is_locked(&gl->gl_spin)); - - printk(KERN_INFO "recursion %016llx, %u\n", gl->gl_name.ln_number, - gl->gl_name.ln_type); - - if (gfs2_assert_warn(sdp, gh->gh_owner)) - return; - - list_for_each_entry_safe(tmp_gh, safe, &gl->gl_waiters3, gh_list) { - if (tmp_gh->gh_owner != gh->gh_owner) - continue; - - gfs2_assert_warn(sdp, - test_bit(HIF_RECURSE, &tmp_gh->gh_iflags)); - - list_move_tail(&tmp_gh->gh_list, &gl->gl_holders); - tmp_gh->gh_error = 0; - set_bit(HIF_HOLDER, &tmp_gh->gh_iflags); - - complete(&tmp_gh->gh_wait); - - found = 1; - } - - gfs2_assert_warn(sdp, found); -} - -/** - * do_unrecurse - a recursive holder was just dropped of the waiters3 list - * @gh: the holder - * - * If there is only one other recursive holder, clear its HIF_RECURSE bit. - * If there is more than one, leave them alone. - * - */ - -static void do_unrecurse(struct gfs2_holder *gh) -{ - struct gfs2_glock *gl = gh->gh_gl; - struct gfs2_sbd *sdp = gl->gl_sbd; - struct gfs2_holder *tmp_gh, *last_gh = NULL; - int found = 0; - - BUG_ON(!spin_is_locked(&gl->gl_spin)); - - if (gfs2_assert_warn(sdp, gh->gh_owner)) - return; - - list_for_each_entry(tmp_gh, &gl->gl_waiters3, gh_list) { - if (tmp_gh->gh_owner != gh->gh_owner) - continue; - - gfs2_assert_warn(sdp, - test_bit(HIF_RECURSE, &tmp_gh->gh_iflags)); - - if (found) - return; - - found = 1; - last_gh = tmp_gh; - } - - if (!gfs2_assert_warn(sdp, found)) - clear_bit(HIF_RECURSE, &last_gh->gh_iflags); -} - /** * rq_mutex - process a mutex request in the queue * @gh: the glock holder @@ -562,7 +482,6 @@ static int rq_promote(struct gfs2_holder *gh) struct gfs2_glock *gl = gh->gh_gl; struct gfs2_sbd *sdp = gl->gl_sbd; struct gfs2_glock_operations *glops = gl->gl_ops; - int recurse; if (!relaxed_state_ok(gl->gl_state, gh->gh_state, gh->gh_flags)) { if (list_empty(&gl->gl_holders)) { @@ -588,7 +507,6 @@ static int rq_promote(struct gfs2_holder *gh) if (list_empty(&gl->gl_holders)) { set_bit(HIF_FIRST, &gh->gh_iflags); set_bit(GLF_LOCK, &gl->gl_flags); - recurse = 0; } else { struct gfs2_holder *next_gh; if (gh->gh_flags & GL_LOCAL_EXCL) @@ -597,16 +515,12 @@ static int rq_promote(struct gfs2_holder *gh) gh_list); if (next_gh->gh_flags & GL_LOCAL_EXCL) return 1; - recurse = test_bit(HIF_RECURSE, &gh->gh_iflags); } list_move_tail(&gh->gh_list, &gl->gl_holders); gh->gh_error = 0; set_bit(HIF_HOLDER, &gh->gh_iflags); - if (recurse) - handle_recurse(gh); - complete(&gh->gh_wait); return 0; @@ -897,8 +811,6 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret) spin_lock(&gl->gl_spin); list_del_init(&gh->gh_list); gh->gh_error = -EIO; - if (test_bit(HIF_RECURSE, &gh->gh_iflags)) - do_unrecurse(gh); spin_unlock(&gl->gl_spin); } else if (test_bit(HIF_DEMOTE, &gh->gh_iflags)) { @@ -922,8 +834,6 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret) spin_lock(&gl->gl_spin); list_del_init(&gh->gh_list); gh->gh_error = GLR_CANCELED; - if (test_bit(HIF_RECURSE, &gh->gh_iflags)) - do_unrecurse(gh); spin_unlock(&gl->gl_spin); } else if (relaxed_state_ok(gl->gl_state, gh->gh_state, gh->gh_flags)) { @@ -941,8 +851,6 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret) spin_lock(&gl->gl_spin); list_del_init(&gh->gh_list); gh->gh_error = GLR_TRYFAILED; - if (test_bit(HIF_RECURSE, &gh->gh_iflags)) - do_unrecurse(gh); spin_unlock(&gl->gl_spin); } else { @@ -1161,8 +1069,6 @@ static int glock_wait_internal(struct gfs2_holder *gh) !list_empty(&gh->gh_list)) { list_del_init(&gh->gh_list); gh->gh_error = GLR_TRYFAILED; - if (test_bit(HIF_RECURSE, &gh->gh_iflags)) - do_unrecurse(gh); run_queue(gl); spin_unlock(&gl->gl_spin); return gh->gh_error; @@ -1191,9 +1097,6 @@ static int glock_wait_internal(struct gfs2_holder *gh) if (gh->gh_error) { spin_lock(&gl->gl_spin); list_del_init(&gh->gh_list); - if (test_and_clear_bit(HIF_RECURSE, - &gh->gh_iflags)) - do_unrecurse(gh); spin_unlock(&gl->gl_spin); } } @@ -1202,8 +1105,6 @@ static int glock_wait_internal(struct gfs2_holder *gh) gl->gl_req_gh = NULL; gl->gl_req_bh = NULL; clear_bit(GLF_LOCK, &gl->gl_flags); - if (test_bit(HIF_RECURSE, &gh->gh_iflags)) - handle_recurse(gh); run_queue(gl); spin_unlock(&gl->gl_spin); } @@ -1224,40 +1125,6 @@ find_holder_by_owner(struct list_head *head, struct task_struct *owner) return NULL; } -/** - * recurse_check - - * - * Make sure the new holder is compatible with the pre-existing one. - * - */ - -static int recurse_check(struct gfs2_holder *existing, struct gfs2_holder *new, - unsigned int state) -{ - struct gfs2_sbd *sdp = existing->gh_gl->gl_sbd; - - if (gfs2_assert_warn(sdp, (new->gh_flags & LM_FLAG_ANY) || - !(existing->gh_flags & LM_FLAG_ANY))) - goto fail; - - if (gfs2_assert_warn(sdp, (existing->gh_flags & GL_LOCAL_EXCL) || - !(new->gh_flags & GL_LOCAL_EXCL))) - goto fail; - - if (gfs2_assert_warn(sdp, relaxed_state_ok(state, new->gh_state, - new->gh_flags))) - goto fail; - - return 0; - -fail: - print_symbol(KERN_WARNING "GFS2: Existing holder from %s\n", - existing->gh_ip); - print_symbol(KERN_WARNING "GFS2: New holder from %s\n", new->gh_ip); - set_bit(HIF_ABORTED, &new->gh_iflags); - return -EINVAL; -} - /** * add_to_queue - Add a holder to the wait queue (but look for recursion) * @gh: the holder structure to add @@ -1271,37 +1138,20 @@ static void add_to_queue(struct gfs2_holder *gh) BUG_ON(!gh->gh_owner); - if (!gh->gh_owner) - goto out; - existing = find_holder_by_owner(&gl->gl_holders, gh->gh_owner); if (existing) { - if (recurse_check(existing, gh, gl->gl_state)) - return; - - list_add_tail(&gh->gh_list, &gl->gl_holders); - set_bit(HIF_HOLDER, &gh->gh_iflags); - - gh->gh_error = 0; - complete(&gh->gh_wait); - - return; + print_symbol(KERN_WARNING "original: %s\n", existing->gh_ip); + print_symbol(KERN_WARNING "new: %s\n", gh->gh_ip); + BUG(); } existing = find_holder_by_owner(&gl->gl_waiters3, gh->gh_owner); if (existing) { - if (recurse_check(existing, gh, existing->gh_state)) - return; - - set_bit(HIF_RECURSE, &gh->gh_iflags); - set_bit(HIF_RECURSE, &existing->gh_iflags); - - list_add_tail(&gh->gh_list, &gl->gl_waiters3); - - return; + print_symbol(KERN_WARNING "original: %s\n", existing->gh_ip); + print_symbol(KERN_WARNING "new: %s\n", gh->gh_ip); + BUG(); } - out: if (gh->gh_flags & LM_FLAG_PRIORITY) list_add(&gh->gh_list, &gl->gl_waiters3); else diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 761f00153d43b6..84dd2f579e62ea 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -146,7 +146,6 @@ enum { HIF_DEALLOC = 5, HIF_HOLDER = 6, HIF_FIRST = 7, - HIF_RECURSE = 8, HIF_ABORTED = 9, }; diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index e91c2bda6c3224..7d467966f92cb4 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -436,30 +436,35 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd) unsigned int pass; int error; - fs_info(sdp, "jid=%u: Trying to acquire journal lock...\n", jd->jd_jid); - - /* Aquire the journal lock so we can do recovery */ - - error = gfs2_glock_nq_num(sdp, jd->jd_jid, &gfs2_journal_glops, - LM_ST_EXCLUSIVE, - LM_FLAG_NOEXP | LM_FLAG_TRY | GL_NOCACHE, - &j_gh); - switch (error) { - case 0: - break; + if (jd->jd_jid != sdp->sd_lockstruct.ls_jid) { + fs_info(sdp, "jid=%u: Trying to acquire journal lock...\n", + jd->jd_jid); - case GLR_TRYFAILED: - fs_info(sdp, "jid=%u: Busy\n", jd->jd_jid); - error = 0; + /* Aquire the journal lock so we can do recovery */ - default: - goto fail; - }; + error = gfs2_glock_nq_num(sdp, jd->jd_jid, &gfs2_journal_glops, + LM_ST_EXCLUSIVE, + LM_FLAG_NOEXP | LM_FLAG_TRY | GL_NOCACHE, + &j_gh); + switch (error) { + case 0: + break; + + case GLR_TRYFAILED: + fs_info(sdp, "jid=%u: Busy\n", jd->jd_jid); + error = 0; + + default: + goto fail; + }; - error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, - LM_FLAG_NOEXP, &ji_gh); - if (error) - goto fail_gunlock_j; + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, + LM_FLAG_NOEXP, &ji_gh); + if (error) + goto fail_gunlock_j; + } else { + fs_info(sdp, "jid=%u, already locked for use\n", jd->jd_jid); + } fs_info(sdp, "jid=%u: Looking at journal...\n", jd->jd_jid); @@ -481,10 +486,8 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd) error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED, - LM_FLAG_NOEXP | - LM_FLAG_PRIORITY | - GL_NEVER_RECURSE | - GL_NOCANCEL | + LM_FLAG_NOEXP | LM_FLAG_PRIORITY | + GL_NEVER_RECURSE | GL_NOCANCEL | GL_NOCACHE, &t_gh); if (error) @@ -521,37 +524,35 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd) goto fail_gunlock_tr; gfs2_glock_dq_uninit(&t_gh); - t = DIV_ROUND_UP(jiffies - t, HZ); - fs_info(sdp, "jid=%u: Journal replayed in %lus\n", jd->jd_jid, t); } - gfs2_glock_dq_uninit(&ji_gh); + if (jd->jd_jid != sdp->sd_lockstruct.ls_jid) + gfs2_glock_dq_uninit(&ji_gh); gfs2_lm_recovery_done(sdp, jd->jd_jid, LM_RD_SUCCESS); - gfs2_glock_dq_uninit(&j_gh); + if (jd->jd_jid != sdp->sd_lockstruct.ls_jid) + gfs2_glock_dq_uninit(&j_gh); fs_info(sdp, "jid=%u: Done\n", jd->jd_jid); - return 0; - fail_gunlock_tr: +fail_gunlock_tr: gfs2_glock_dq_uninit(&t_gh); - - fail_gunlock_ji: - gfs2_glock_dq_uninit(&ji_gh); - - fail_gunlock_j: - gfs2_glock_dq_uninit(&j_gh); +fail_gunlock_ji: + if (jd->jd_jid != sdp->sd_lockstruct.ls_jid) { + gfs2_glock_dq_uninit(&ji_gh); +fail_gunlock_j: + gfs2_glock_dq_uninit(&j_gh); + } fs_info(sdp, "jid=%u: %s\n", jd->jd_jid, (error) ? "Failed" : "Done"); - fail: +fail: gfs2_lm_recovery_done(sdp, jd->jd_jid, LM_RD_GAVEUP); - return error; } -- cgit 1.2.3-korg From 579b78a43b366d51f9c888afaf1eab1f4ea599fa Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 26 Apr 2006 14:58:26 -0400 Subject: [GFS2] Remove GL_NEVER_RECURSE flag There is no point in keeping this flag since recursion is not now allowed for any glock. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 10 ++++------ fs/gfs2/glock.h | 1 - fs/gfs2/ops_fstype.c | 10 +++++----- fs/gfs2/recovery.c | 3 +-- fs/gfs2/super.c | 6 +++--- fs/gfs2/trans.c | 3 +-- 6 files changed, 14 insertions(+), 19 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 0f317155915d14..67e3f2a4d109f4 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -357,7 +357,6 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, unsigned flags, struct gfs2_holder *gh) { - flags |= GL_NEVER_RECURSE; INIT_LIST_HEAD(&gh->gh_list); gh->gh_gl = gl; gh->gh_ip = (unsigned long)__builtin_return_address(0); @@ -387,7 +386,7 @@ void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, unsigned flags, void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *gh) { gh->gh_state = state; - gh->gh_flags = flags | GL_NEVER_RECURSE; + gh->gh_flags = flags; if (gh->gh_state == LM_ST_EXCLUSIVE) gh->gh_flags |= GL_LOCAL_EXCL; @@ -731,8 +730,7 @@ static void handle_callback(struct gfs2_glock *gl, unsigned int state) } else { spin_unlock(&gl->gl_spin); - new_gh = gfs2_holder_get(gl, state, - LM_FLAG_TRY | GL_NEVER_RECURSE, + new_gh = gfs2_holder_get(gl, state, LM_FLAG_TRY, GFP_KERNEL | __GFP_NOFAIL), set_bit(HIF_DEMOTE, &new_gh->gh_iflags); set_bit(HIF_DEALLOC, &new_gh->gh_iflags); @@ -1336,7 +1334,7 @@ void gfs2_glock_force_drop(struct gfs2_glock *gl) { struct gfs2_holder gh; - gfs2_holder_init(gl, LM_ST_UNLOCKED, GL_NEVER_RECURSE, &gh); + gfs2_holder_init(gl, LM_ST_UNLOCKED, 0, &gh); set_bit(HIF_DEMOTE, &gh.gh_iflags); spin_lock(&gl->gl_spin); @@ -1401,7 +1399,7 @@ int gfs2_glock_be_greedy(struct gfs2_glock *gl, unsigned int time) } gh = &gr->gr_gh; - gfs2_holder_init(gl, 0, GL_NEVER_RECURSE, gh); + gfs2_holder_init(gl, 0, 0, gh); set_bit(HIF_GREEDY, &gh->gh_iflags); INIT_WORK(&gr->gr_work, greedy_work, gr); diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index ed5bc3e65397f1..6f9c88ed538309 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -26,7 +26,6 @@ #define GL_NOCACHE 0x00000400 #define GL_SYNC 0x00000800 #define GL_NOCANCEL 0x00001000 -#define GL_NEVER_RECURSE 0x00002000 #define GL_AOP 0x00004000 #define GLR_TRYFAILED 13 diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 70745f3561a6bd..d19d98766aa5cd 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -223,7 +223,7 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh, error = gfs2_glock_nq_num(sdp, GFS2_LIVE_LOCK, &gfs2_nondisk_glops, LM_ST_SHARED, - LM_FLAG_NOEXP | GL_EXACT | GL_NEVER_RECURSE, + LM_FLAG_NOEXP | GL_EXACT, &sdp->sd_live_gh); if (error) { fs_err(sdp, "can't acquire live glock: %d\n", error); @@ -638,7 +638,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) ip = sdp->sd_ir_inode->u.generic_ip; error = gfs2_glock_nq_init(ip->i_gl, - LM_ST_EXCLUSIVE, GL_NEVER_RECURSE, + LM_ST_EXCLUSIVE, 0, &sdp->sd_ir_gh); if (error) { fs_err(sdp, "can't lock local \"ir\" file: %d\n", error); @@ -647,7 +647,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) ip = sdp->sd_sc_inode->u.generic_ip; error = gfs2_glock_nq_init(ip->i_gl, - LM_ST_EXCLUSIVE, GL_NEVER_RECURSE, + LM_ST_EXCLUSIVE, 0, &sdp->sd_sc_gh); if (error) { fs_err(sdp, "can't lock local \"sc\" file: %d\n", error); @@ -656,7 +656,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) ip = sdp->sd_ut_inode->u.generic_ip; error = gfs2_glock_nq_init(ip->i_gl, - LM_ST_EXCLUSIVE, GL_NEVER_RECURSE, + LM_ST_EXCLUSIVE, 0, &sdp->sd_ut_gh); if (error) { fs_err(sdp, "can't lock local \"ut\" file: %d\n", error); @@ -665,7 +665,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) ip = sdp->sd_qc_inode->u.generic_ip; error = gfs2_glock_nq_init(ip->i_gl, - LM_ST_EXCLUSIVE, GL_NEVER_RECURSE, + LM_ST_EXCLUSIVE, 0, &sdp->sd_qc_gh); if (error) { fs_err(sdp, "can't lock local \"qc\" file: %d\n", error); diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index 7d467966f92cb4..d916817fb6e3c2 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -487,8 +487,7 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd) error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED, LM_FLAG_NOEXP | LM_FLAG_PRIORITY | - GL_NEVER_RECURSE | GL_NOCANCEL | - GL_NOCACHE, + GL_NOCANCEL | GL_NOCACHE, &t_gh); if (error) goto fail_gunlock_ji; diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index a4da649d086f94..f0dbd2d7aadc03 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -469,7 +469,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp) int error; error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED, - GL_LOCAL_EXCL | GL_NEVER_RECURSE, &t_gh); + GL_LOCAL_EXCL, &t_gh); if (error) return error; @@ -530,7 +530,7 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp) gfs2_statfs_sync(sdp); error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED, - GL_LOCAL_EXCL | GL_NEVER_RECURSE | GL_NOCACHE, + GL_LOCAL_EXCL | GL_NOCACHE, &t_gh); if (error && !test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) return error; @@ -869,7 +869,7 @@ int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, struct gfs2_holder *t_gh) } error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_DEFERRED, - LM_FLAG_PRIORITY | GL_NEVER_RECURSE | GL_NOCACHE, + LM_FLAG_PRIORITY | GL_NOCACHE, t_gh); list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index 6b02d8c38f0f01..18c606d0712653 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -50,8 +50,7 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks, sizeof(uint64_t)); INIT_LIST_HEAD(&tr->tr_list_buf); - gfs2_holder_init(sdp->sd_trans_gl, LM_ST_SHARED, - GL_NEVER_RECURSE, &tr->tr_t_gh); + gfs2_holder_init(sdp->sd_trans_gl, LM_ST_SHARED, 0, &tr->tr_t_gh); error = gfs2_glock_nq(&tr->tr_t_gh); if (error) -- cgit 1.2.3-korg From e7f5c01caddbad150dcf003f76cd5aac413f4c50 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 27 Apr 2006 11:25:45 -0400 Subject: [GFS2] Remove redundant casts to/from void Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 11 +++++------ fs/gfs2/locking/dlm/lock.c | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 67e3f2a4d109f4..17d474fab5ab26 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1348,7 +1348,7 @@ void gfs2_glock_force_drop(struct gfs2_glock *gl) static void greedy_work(void *data) { - struct greedy *gr = (struct greedy *)data; + struct greedy *gr = data; struct gfs2_holder *gh = &gr->gr_gh; struct gfs2_glock *gl = gh->gh_gl; struct gfs2_glock_operations *glops = gl->gl_ops; @@ -1745,19 +1745,19 @@ void gfs2_glock_cb(lm_fsdata_t *fsdata, unsigned int type, void *data) switch (type) { case LM_CB_NEED_E: - blocking_cb(sdp, (struct lm_lockname *)data, LM_ST_UNLOCKED); + blocking_cb(sdp, data, LM_ST_UNLOCKED); return; case LM_CB_NEED_D: - blocking_cb(sdp, (struct lm_lockname *)data, LM_ST_DEFERRED); + blocking_cb(sdp, data, LM_ST_DEFERRED); return; case LM_CB_NEED_S: - blocking_cb(sdp, (struct lm_lockname *)data, LM_ST_SHARED); + blocking_cb(sdp, data, LM_ST_SHARED); return; case LM_CB_ASYNC: { - struct lm_async_cb *async = (struct lm_async_cb *)data; + struct lm_async_cb *async = data; struct gfs2_glock *gl; gl = gfs2_glock_find(sdp, &async->lc_name); @@ -1766,7 +1766,6 @@ void gfs2_glock_cb(lm_fsdata_t *fsdata, unsigned int type, void *data) if (!gfs2_assert_warn(sdp, gl->gl_req_bh)) gl->gl_req_bh(gl, async->lc_ret); gfs2_glock_put(gl); - return; } diff --git a/fs/gfs2/locking/dlm/lock.c b/fs/gfs2/locking/dlm/lock.c index 1799d2237e7e35..a309b799dff1f2 100644 --- a/fs/gfs2/locking/dlm/lock.c +++ b/fs/gfs2/locking/dlm/lock.c @@ -25,7 +25,7 @@ static void queue_complete(struct gdlm_lock *lp) static inline void gdlm_ast(void *astarg) { - queue_complete((struct gdlm_lock *) astarg); + queue_complete(astarg); } static inline void gdlm_bast(void *astarg, int mode) @@ -257,7 +257,7 @@ unsigned int gdlm_do_lock(struct gdlm_lock *lp) lp->cur, lp->req, lp->lkf); error = dlm_lock(ls->dlm_lockspace, lp->req, &lp->lksb, lp->lkf, - str.name, str.namelen, 0, gdlm_ast, (void *) lp, + str.name, str.namelen, 0, gdlm_ast, lp, bast ? gdlm_bast : NULL); if ((error == -EAGAIN) && (lp->lkf & DLM_LKF_NOQUEUE)) { -- cgit 1.2.3-korg From 363275216c1a1b0b82c8419310c194b8c26b9c27 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Fri, 28 Apr 2006 10:46:21 -0400 Subject: [GFS2] Reordering in deallocation to avoid recursive locking Despite my earlier careful search, there was a recursive lock left in the deallocation code. This removes it. It also should speed up deallocation be reducing the number of locking operations which take place by using two "try lock" operations on the two locks involved in inode deallocation which allows us to grab the locks out of order (compared with NFS which grabs the inode lock first and the iopen lock later). It is ok for us to fail while doing this since if it does fail it means that someone else is still using the inode and thus it wouldn't be possible to deallocate anyway. This fixes the bug reported to me by Rob Kenna. Cc: Rob Kenna Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 6 ++-- fs/gfs2/inode.c | 95 +++++++++++++++++++++++++++------------------------------ fs/gfs2/inode.h | 2 +- 3 files changed, 49 insertions(+), 54 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 17d474fab5ab26..f82ecc0cc8fbbe 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1814,7 +1814,7 @@ void gfs2_try_toss_inode(struct gfs2_sbd *sdp, struct gfs2_inum *inum) if (atomic_read(&ip->i_count)) goto out_unlock; - gfs2_inode_destroy(ip); + gfs2_inode_destroy(ip, 1); out_unlock: gfs2_glmutex_unlock(gl); @@ -1940,7 +1940,7 @@ void gfs2_reclaim_glock(struct gfs2_sbd *sdp) if (gl->gl_ops == &gfs2_inode_glops) { struct gfs2_inode *ip = gl->gl_object; if (ip && !atomic_read(&ip->i_count)) - gfs2_inode_destroy(ip); + gfs2_inode_destroy(ip, 1); } if (queue_empty(gl, &gl->gl_holders) && gl->gl_state != LM_ST_UNLOCKED && @@ -2083,7 +2083,7 @@ static void clear_glock(struct gfs2_glock *gl) if (gl->gl_ops == &gfs2_inode_glops) { struct gfs2_inode *ip = gl->gl_object; if (ip && !atomic_read(&ip->i_count)) - gfs2_inode_destroy(ip); + gfs2_inode_destroy(ip, 1); } if (queue_empty(gl, &gl->gl_holders) && gl->gl_state != LM_ST_UNLOCKED) diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index fb5a4d06e926b5..9084d6037a0cd2 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -287,7 +287,7 @@ int gfs2_inode_refresh(struct gfs2_inode *ip) static int inode_create(struct gfs2_glock *i_gl, const struct gfs2_inum *inum, struct gfs2_glock *io_gl, unsigned int io_state, - struct gfs2_inode **ipp) + struct gfs2_inode **ipp, int need_lock) { struct gfs2_sbd *sdp = i_gl->gl_sbd; struct gfs2_inode *ip; @@ -312,11 +312,13 @@ static int inode_create(struct gfs2_glock *i_gl, const struct gfs2_inum *inum, ip->i_greedy = gfs2_tune_get(sdp, gt_greedy_default); - error = gfs2_glock_nq_init(io_gl, - io_state, GL_LOCAL_EXCL | GL_EXACT, - &ip->i_iopen_gh); - if (error) - goto fail; + if (need_lock) { + error = gfs2_glock_nq_init(io_gl, + io_state, GL_LOCAL_EXCL | GL_EXACT, + &ip->i_iopen_gh); + if (error) + goto fail; + } ip->i_iopen_gh.gh_owner = NULL; spin_lock(&io_gl->gl_spin); @@ -376,7 +378,7 @@ int gfs2_inode_get(struct gfs2_glock *i_gl, const struct gfs2_inum *inum, error = gfs2_glock_get(sdp, inum->no_addr, &gfs2_iopen_glops, CREATE, &io_gl); if (!error) { - error = inode_create(i_gl, inum, io_gl, LM_ST_SHARED, ipp); + error = inode_create(i_gl, inum, io_gl, LM_ST_SHARED, ipp, 1); gfs2_glock_put(io_gl); } @@ -398,21 +400,23 @@ void gfs2_inode_put(struct gfs2_inode *ip) atomic_dec(&ip->i_count); } -void gfs2_inode_destroy(struct gfs2_inode *ip) +void gfs2_inode_destroy(struct gfs2_inode *ip, int unlock) { struct gfs2_sbd *sdp = ip->i_sbd; - struct gfs2_glock *io_gl = ip->i_iopen_gh.gh_gl; struct gfs2_glock *i_gl = ip->i_gl; gfs2_assert_warn(sdp, !atomic_read(&ip->i_count)); - gfs2_assert(sdp, io_gl->gl_object == i_gl); - - spin_lock(&io_gl->gl_spin); - io_gl->gl_object = NULL; - spin_unlock(&io_gl->gl_spin); - gfs2_glock_put(i_gl); - - gfs2_glock_dq_uninit(&ip->i_iopen_gh); + if (unlock) { + struct gfs2_glock *io_gl = ip->i_iopen_gh.gh_gl; + gfs2_assert(sdp, io_gl->gl_object == i_gl); + + spin_lock(&io_gl->gl_spin); + io_gl->gl_object = NULL; + spin_unlock(&io_gl->gl_spin); + gfs2_glock_put(i_gl); + + gfs2_glock_dq_uninit(&ip->i_iopen_gh); + } gfs2_meta_cache_flush(ip); kmem_cache_free(gfs2_inode_cachep, ip); @@ -493,6 +497,13 @@ static int dinode_dealloc(struct gfs2_inode *ip, struct gfs2_unlinked *ul) * @inum: the inode number to deallocate * @io_gh: a holder for the iopen glock for this inode * + * N.B. When we enter this we already hold the iopen glock and getting + * the glock for the inode means that we are grabbing the locks in the + * "wrong" order so we must only so a try lock operation and fail if we + * don't get the lock. Thats ok, since if we fail it means someone else + * is using the inode still and thus we shouldn't be deallocating it + * anyway. + * * Returns: errno */ @@ -503,33 +514,21 @@ static int inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul, struct gfs2_holder i_gh; int error; - error = gfs2_glock_nq_num(sdp, - ul->ul_ut.ut_inum.no_addr, &gfs2_inode_glops, - LM_ST_EXCLUSIVE, 0, &i_gh); - if (error) - return error; - - /* We reacquire the iopen lock here to avoid a race with the NFS server - calling gfs2_read_inode() with the inode number of a inode we're in - the process of deallocating. And we can't keep our hold on the lock - from inode_dealloc_init() for deadlock reasons. */ - - gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY, io_gh); - error = gfs2_glock_nq(io_gh); - switch (error) { + error = gfs2_glock_nq_num(sdp, ul->ul_ut.ut_inum.no_addr, + &gfs2_inode_glops, LM_ST_EXCLUSIVE, + LM_FLAG_TRY_1CB, &i_gh); + switch(error) { case 0: break; case GLR_TRYFAILED: - error = 1; + return 1; /* or back off and relock in different order? */ default: - goto out; + return error; } gfs2_assert_warn(sdp, !i_gh.gh_gl->gl_object); error = inode_create(i_gh.gh_gl, &ul->ul_ut.ut_inum, io_gh->gh_gl, - LM_ST_EXCLUSIVE, &ip); - - gfs2_glock_dq(io_gh); + LM_ST_EXCLUSIVE, &ip, 0); if (error) goto out; @@ -568,13 +567,13 @@ static int inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul, if (error) goto out_iput; - out_iput: +out_iput: gfs2_glmutex_lock(i_gh.gh_gl); gfs2_inode_put(ip); - gfs2_inode_destroy(ip); + gfs2_inode_destroy(ip, 0); gfs2_glmutex_unlock(i_gh.gh_gl); - out: +out: gfs2_glock_dq_uninit(&i_gh); return error; @@ -589,14 +588,13 @@ static int inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul, static int try_inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul) { - struct gfs2_holder io_gh; int error = 0; + struct gfs2_holder iogh; gfs2_try_toss_inode(sdp, &ul->ul_ut.ut_inum); - - error = gfs2_glock_nq_num(sdp, - ul->ul_ut.ut_inum.no_addr, &gfs2_iopen_glops, - LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB, &io_gh); + error = gfs2_glock_nq_num(sdp, ul->ul_ut.ut_inum.no_addr, + &gfs2_iopen_glops, LM_ST_EXCLUSIVE, + LM_FLAG_TRY_1CB, &iogh); switch (error) { case 0: break; @@ -606,9 +604,8 @@ static int try_inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul) return error; } - gfs2_glock_dq(&io_gh); - error = inode_dealloc(sdp, ul, &io_gh); - gfs2_holder_uninit(&io_gh); + error = inode_dealloc(sdp, ul, &iogh); + gfs2_glock_dq_uninit(&iogh); return error; } @@ -634,9 +631,7 @@ static int inode_dealloc_uninit(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul) if (error) goto out; - error = gfs2_trans_begin(sdp, - RES_RG_BIT + RES_UNLINKED + RES_STATFS, - 0); + error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_UNLINKED + RES_STATFS, 0); if (error) goto out_gunlock; diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h index 0dd2a26626ec16..13bc4eacac6b0e 100644 --- a/fs/gfs2/inode.h +++ b/fs/gfs2/inode.h @@ -39,7 +39,7 @@ int gfs2_inode_get(struct gfs2_glock *i_gl, struct gfs2_inode **ipp); void gfs2_inode_hold(struct gfs2_inode *ip); void gfs2_inode_put(struct gfs2_inode *ip); -void gfs2_inode_destroy(struct gfs2_inode *ip); +void gfs2_inode_destroy(struct gfs2_inode *ip, int unlock); int gfs2_inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul); -- cgit 1.2.3-korg From 08bc2dbc7327e89b9d5b9c8ef9401d1df2622fca Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 28 Apr 2006 10:59:12 -0400 Subject: [GFS2] [-mm patch] fs/gfs2/: possible cleanups This patch contains the following possible cleanups: - make needlessly global code static - #if 0 unused functions - remove the following global function that was both unused and unimplemented: - super.c: gfs2_do_upgrade() Signed-off-by: Adrian Bunk Signed-off-by: Steven Whitehouse --- fs/gfs2/bmap.c | 3 ++- fs/gfs2/bmap.h | 2 -- fs/gfs2/dir.c | 8 ++++---- fs/gfs2/eaops.c | 2 +- fs/gfs2/eaops.h | 1 - fs/gfs2/eattr.c | 3 +++ fs/gfs2/eattr.h | 2 -- fs/gfs2/glock.c | 25 ++++++++++++++++--------- fs/gfs2/glock.h | 12 ------------ fs/gfs2/lm.c | 2 ++ fs/gfs2/lm.h | 1 - fs/gfs2/locking/dlm/lock.c | 10 +++++----- fs/gfs2/locking/dlm/lock_dlm.h | 4 ---- fs/gfs2/locking/dlm/main.c | 4 ++-- fs/gfs2/locking/nolock/main.c | 8 ++++---- fs/gfs2/lvb.c | 2 ++ fs/gfs2/lvb.h | 1 - fs/gfs2/ondisk.c | 38 ++++++++++++++++++++++++++++++++++---- fs/gfs2/quota.c | 2 ++ fs/gfs2/quota.h | 2 -- fs/gfs2/super.c | 8 ++------ fs/gfs2/super.h | 2 -- include/linux/gfs2_ondisk.h | 14 -------------- 23 files changed, 79 insertions(+), 77 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 68bc3be09c98eb..f570d8caef6893 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -59,7 +59,7 @@ struct strip_mine { * * Returns: errno */ - +#if 0 int gfs2_unstuffer_sync(struct gfs2_inode *ip, struct buffer_head *dibh, uint64_t block, void *private) { @@ -77,6 +77,7 @@ int gfs2_unstuffer_sync(struct gfs2_inode *ip, struct buffer_head *dibh, return error; } +#endif /* 0 */ /** * gfs2_unstuff_dinode - Unstuff a dinode when the data has grown too big diff --git a/fs/gfs2/bmap.h b/fs/gfs2/bmap.h index ee9ec8d7515c44..23fb6589d5e305 100644 --- a/fs/gfs2/bmap.h +++ b/fs/gfs2/bmap.h @@ -13,8 +13,6 @@ typedef int (*gfs2_unstuffer_t) (struct gfs2_inode * ip, struct buffer_head * dibh, uint64_t block, void *private); -int gfs2_unstuffer_sync(struct gfs2_inode *ip, struct buffer_head *dibh, - uint64_t block, void *private); int gfs2_unstuff_dinode(struct gfs2_inode *ip, gfs2_unstuffer_t unstuffer, void *private); diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index ffc1beff6703e6..0404783f39b385 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -669,10 +669,10 @@ static void dirent_del(struct gfs2_inode *dip, struct buffer_head *bh, * Takes a dent from which to grab space as an argument. Returns the * newly created dent. */ -struct gfs2_dirent *gfs2_init_dirent(struct inode *inode, - struct gfs2_dirent *dent, - const struct qstr *name, - struct buffer_head *bh) +static struct gfs2_dirent *gfs2_init_dirent(struct inode *inode, + struct gfs2_dirent *dent, + const struct qstr *name, + struct buffer_head *bh) { struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_dirent *ndent; diff --git a/fs/gfs2/eaops.c b/fs/gfs2/eaops.c index 4b9f6cff7a3487..1b376eceb6af52 100644 --- a/fs/gfs2/eaops.c +++ b/fs/gfs2/eaops.c @@ -167,7 +167,7 @@ static int system_eo_remove(struct gfs2_inode *ip, struct gfs2_ea_request *er) return gfs2_ea_remove_i(ip, er); } -struct gfs2_eattr_operations gfs2_user_eaops = { +static struct gfs2_eattr_operations gfs2_user_eaops = { .eo_get = user_eo_get, .eo_set = user_eo_set, .eo_remove = user_eo_remove, diff --git a/fs/gfs2/eaops.h b/fs/gfs2/eaops.h index f83c497eddcad4..30ec6a09bfd0ff 100644 --- a/fs/gfs2/eaops.h +++ b/fs/gfs2/eaops.h @@ -21,7 +21,6 @@ struct gfs2_eattr_operations { unsigned int gfs2_ea_name2type(const char *name, char **truncated_name); -extern struct gfs2_eattr_operations gfs2_user_eaops; extern struct gfs2_eattr_operations gfs2_system_eaops; extern struct gfs2_eattr_operations *gfs2_ea_ops[]; diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c index 8219d471f06c6e..d3316cab2be46b 100644 --- a/fs/gfs2/eattr.c +++ b/fs/gfs2/eattr.c @@ -358,6 +358,7 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, return error; } +#if 0 static int gfs2_ea_repack_i(struct gfs2_inode *ip) { @@ -382,6 +383,8 @@ int gfs2_ea_repack(struct gfs2_inode *ip) return error; } +#endif /* 0 */ + struct ea_list { struct gfs2_ea_request *ei_er; unsigned int ei_size; diff --git a/fs/gfs2/eattr.h b/fs/gfs2/eattr.h index 2b4152b1fcbef9..ffd56686225ba9 100644 --- a/fs/gfs2/eattr.h +++ b/fs/gfs2/eattr.h @@ -61,8 +61,6 @@ struct gfs2_ea_location { struct gfs2_ea_header *el_prev; }; -int gfs2_ea_repack(struct gfs2_inode *ip); - int gfs2_ea_get_i(struct gfs2_inode *ip, struct gfs2_ea_request *er); int gfs2_ea_set_i(struct gfs2_inode *ip, struct gfs2_ea_request *er); int gfs2_ea_remove_i(struct gfs2_inode *ip, struct gfs2_ea_request *er); diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index f82ecc0cc8fbbe..0a5a0e87b0a6ba 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -47,6 +47,8 @@ struct greedy { typedef void (*glock_examiner) (struct gfs2_glock * gl); +static int gfs2_dump_lockstate(struct gfs2_sbd *sdp); + /** * relaxed_state_ok - is a requested lock compatible with the current lock mode? * @actual: the current state of the lock @@ -228,8 +230,8 @@ static struct gfs2_glock *search_bucket(struct gfs2_gl_hash_bucket *bucket, * Returns: NULL, or the struct gfs2_glock with the requested number */ -struct gfs2_glock *gfs2_glock_find(struct gfs2_sbd *sdp, - struct lm_lockname *name) +static struct gfs2_glock *gfs2_glock_find(struct gfs2_sbd *sdp, + struct lm_lockname *name) { struct gfs2_gl_hash_bucket *bucket = &sdp->sd_gl_hash[gl_hash(name)]; struct gfs2_glock *gl; @@ -421,8 +423,9 @@ void gfs2_holder_uninit(struct gfs2_holder *gh) * Returns: the holder structure, NULL on ENOMEM */ -struct gfs2_holder *gfs2_holder_get(struct gfs2_glock *gl, unsigned int state, - int flags, gfp_t gfp_flags) +static struct gfs2_holder *gfs2_holder_get(struct gfs2_glock *gl, + unsigned int state, + int flags, gfp_t gfp_flags) { struct gfs2_holder *gh; @@ -442,7 +445,7 @@ struct gfs2_holder *gfs2_holder_get(struct gfs2_glock *gl, unsigned int state, * */ -void gfs2_holder_put(struct gfs2_holder *gh) +static void gfs2_holder_put(struct gfs2_holder *gh) { gfs2_holder_uninit(gh); kfree(gh); @@ -674,7 +677,7 @@ void gfs2_glmutex_lock(struct gfs2_glock *gl) * Returns: 1 if the glock is acquired */ -int gfs2_glmutex_trylock(struct gfs2_glock *gl) +static int gfs2_glmutex_trylock(struct gfs2_glock *gl) { int acquired = 1; @@ -1301,7 +1304,8 @@ void gfs2_glock_dq(struct gfs2_holder *gh) * */ -void gfs2_glock_prefetch(struct gfs2_glock *gl, unsigned int state, int flags) +static void gfs2_glock_prefetch(struct gfs2_glock *gl, unsigned int state, + int flags) { struct gfs2_glock_operations *glops = gl->gl_ops; @@ -1329,7 +1333,7 @@ void gfs2_glock_prefetch(struct gfs2_glock *gl, unsigned int state, int flags) * @gl: the glock * */ - +#if 0 void gfs2_glock_force_drop(struct gfs2_glock *gl) { struct gfs2_holder gh; @@ -1345,6 +1349,7 @@ void gfs2_glock_force_drop(struct gfs2_glock *gl) wait_for_completion(&gh.gh_wait); gfs2_holder_uninit(&gh); } +#endif /* 0 */ static void greedy_work(void *data) { @@ -1697,6 +1702,7 @@ void gfs2_lvb_unhold(struct gfs2_glock *gl) gfs2_glock_put(gl); } +#if 0 void gfs2_lvb_sync(struct gfs2_glock *gl) { gfs2_glmutex_lock(gl); @@ -1707,6 +1713,7 @@ void gfs2_lvb_sync(struct gfs2_glock *gl) gfs2_glmutex_unlock(gl); } +#endif /* 0 */ static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name, unsigned int state) @@ -2307,7 +2314,7 @@ static int dump_glock(struct gfs2_glock *gl) * */ -int gfs2_dump_lockstate(struct gfs2_sbd *sdp) +static int gfs2_dump_lockstate(struct gfs2_sbd *sdp) { struct gfs2_gl_hash_bucket *bucket; struct gfs2_glock *gl; diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 6f9c88ed538309..a36b26585fb83e 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -73,8 +73,6 @@ static inline int gfs2_glock_is_blocking(struct gfs2_glock *gl) return ret; } -struct gfs2_glock *gfs2_glock_find(struct gfs2_sbd *sdp, - struct lm_lockname *name); int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, struct gfs2_glock_operations *glops, int create, struct gfs2_glock **glp); @@ -85,15 +83,11 @@ void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, unsigned flags, void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *gh); void gfs2_holder_uninit(struct gfs2_holder *gh); -struct gfs2_holder *gfs2_holder_get(struct gfs2_glock *gl, unsigned int state, - int flags, gfp_t gfp_flags); -void gfs2_holder_put(struct gfs2_holder *gh); void gfs2_glock_xmote_th(struct gfs2_glock *gl, unsigned int state, int flags); void gfs2_glock_drop_th(struct gfs2_glock *gl); void gfs2_glmutex_lock(struct gfs2_glock *gl); -int gfs2_glmutex_trylock(struct gfs2_glock *gl); void gfs2_glmutex_unlock(struct gfs2_glock *gl); int gfs2_glock_nq(struct gfs2_holder *gh); @@ -101,9 +95,6 @@ int gfs2_glock_poll(struct gfs2_holder *gh); int gfs2_glock_wait(struct gfs2_holder *gh); void gfs2_glock_dq(struct gfs2_holder *gh); -void gfs2_glock_prefetch(struct gfs2_glock *gl, unsigned int state, int flags); -void gfs2_glock_force_drop(struct gfs2_glock *gl); - int gfs2_glock_be_greedy(struct gfs2_glock *gl, unsigned int time); void gfs2_glock_dq_uninit(struct gfs2_holder *gh); @@ -148,7 +139,6 @@ static inline int gfs2_glock_nq_init(struct gfs2_glock *gl, int gfs2_lvb_hold(struct gfs2_glock *gl); void gfs2_lvb_unhold(struct gfs2_glock *gl); -void gfs2_lvb_sync(struct gfs2_glock *gl); void gfs2_glock_cb(lm_fsdata_t *fsdata, unsigned int type, void *data); @@ -161,6 +151,4 @@ void gfs2_reclaim_glock(struct gfs2_sbd *sdp); void gfs2_scand_internal(struct gfs2_sbd *sdp); void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait); -int gfs2_dump_lockstate(struct gfs2_sbd *sdp); - #endif /* __GLOCK_DOT_H__ */ diff --git a/fs/gfs2/lm.c b/fs/gfs2/lm.c index 5b3c56d2df2fdc..06a785e9b58229 100644 --- a/fs/gfs2/lm.c +++ b/fs/gfs2/lm.c @@ -188,11 +188,13 @@ void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb) sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(lock, lvb); } +#if 0 void gfs2_lm_sync_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb) { if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) sdp->sd_lockstruct.ls_ops->lm_sync_lvb(lock, lvb); } +#endif /* 0 */ int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name, struct file *file, struct file_lock *fl) diff --git a/fs/gfs2/lm.h b/fs/gfs2/lm.h index ec812424fdec8d..4ee5c34434bc6b 100644 --- a/fs/gfs2/lm.h +++ b/fs/gfs2/lm.h @@ -26,7 +26,6 @@ unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, lm_lock_t *lock, void gfs2_lm_cancel(struct gfs2_sbd *sdp, lm_lock_t *lock); int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char **lvbp); void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb); -void gfs2_lm_sync_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb); int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name, struct file *file, struct file_lock *fl); diff --git a/fs/gfs2/locking/dlm/lock.c b/fs/gfs2/locking/dlm/lock.c index a309b799dff1f2..3b0dfd7ae26e64 100644 --- a/fs/gfs2/locking/dlm/lock.c +++ b/fs/gfs2/locking/dlm/lock.c @@ -158,8 +158,8 @@ static inline void make_strname(struct lm_lockname *lockname, str->namelen = GDLM_STRNAME_BYTES; } -int gdlm_create_lp(struct gdlm_ls *ls, struct lm_lockname *name, - struct gdlm_lock **lpp) +static int gdlm_create_lp(struct gdlm_ls *ls, struct lm_lockname *name, + struct gdlm_lock **lpp) { struct gdlm_lock *lp; @@ -276,7 +276,7 @@ unsigned int gdlm_do_lock(struct gdlm_lock *lp) return LM_OUT_ASYNC; } -unsigned int gdlm_do_unlock(struct gdlm_lock *lp) +static unsigned int gdlm_do_unlock(struct gdlm_lock *lp) { struct gdlm_ls *ls = lp->ls; unsigned int lkf = 0; @@ -378,7 +378,7 @@ void gdlm_cancel(lm_lock_t *lock) clear_bit(LFL_DLM_CANCEL, &lp->flags); } -int gdlm_add_lvb(struct gdlm_lock *lp) +static int gdlm_add_lvb(struct gdlm_lock *lp) { char *lvb; @@ -391,7 +391,7 @@ int gdlm_add_lvb(struct gdlm_lock *lp) return 0; } -void gdlm_del_lvb(struct gdlm_lock *lp) +static void gdlm_del_lvb(struct gdlm_lock *lp) { kfree(lp->lvb); lp->lvb = NULL; diff --git a/fs/gfs2/locking/dlm/lock_dlm.h b/fs/gfs2/locking/dlm/lock_dlm.h index e6c1e4786fec05..530c2f542584da 100644 --- a/fs/gfs2/locking/dlm/lock_dlm.h +++ b/fs/gfs2/locking/dlm/lock_dlm.h @@ -162,12 +162,8 @@ int16_t gdlm_make_lmstate(int16_t); void gdlm_queue_delayed(struct gdlm_lock *); void gdlm_submit_delayed(struct gdlm_ls *); int gdlm_release_all_locks(struct gdlm_ls *); -int gdlm_create_lp(struct gdlm_ls *, struct lm_lockname *, struct gdlm_lock **); void gdlm_delete_lp(struct gdlm_lock *); -int gdlm_add_lvb(struct gdlm_lock *); -void gdlm_del_lvb(struct gdlm_lock *); unsigned int gdlm_do_lock(struct gdlm_lock *); -unsigned int gdlm_do_unlock(struct gdlm_lock *); int gdlm_get_lock(lm_lockspace_t *, struct lm_lockname *, lm_lock_t **); void gdlm_put_lock(lm_lock_t *); diff --git a/fs/gfs2/locking/dlm/main.c b/fs/gfs2/locking/dlm/main.c index 3c9adf18fd9c31..89728c91665fe9 100644 --- a/fs/gfs2/locking/dlm/main.c +++ b/fs/gfs2/locking/dlm/main.c @@ -16,7 +16,7 @@ extern int gdlm_drop_period; extern struct lm_lockops gdlm_ops; -int __init init_lock_dlm(void) +static int __init init_lock_dlm(void) { int error; @@ -48,7 +48,7 @@ int __init init_lock_dlm(void) return 0; } -void __exit exit_lock_dlm(void) +static void __exit exit_lock_dlm(void) { gdlm_plock_exit(); gdlm_sysfs_exit(); diff --git a/fs/gfs2/locking/nolock/main.c b/fs/gfs2/locking/nolock/main.c index ecd37371eba5fd..97ffac5cdefbe5 100644 --- a/fs/gfs2/locking/nolock/main.c +++ b/fs/gfs2/locking/nolock/main.c @@ -21,7 +21,7 @@ struct nolock_lockspace { unsigned int nl_lvb_size; }; -struct lm_lockops nolock_ops; +static struct lm_lockops nolock_ops; static int nolock_mount(char *table_name, char *host_data, lm_callback_t cb, lm_fsdata_t *fsdata, @@ -208,7 +208,7 @@ static void nolock_recovery_done(lm_lockspace_t *lockspace, unsigned int jid, { } -struct lm_lockops nolock_ops = { +static struct lm_lockops nolock_ops = { .lm_proto_name = "lock_nolock", .lm_mount = nolock_mount, .lm_others_may_mount = nolock_others_may_mount, @@ -229,7 +229,7 @@ struct lm_lockops nolock_ops = { .lm_owner = THIS_MODULE, }; -int __init init_nolock(void) +static int __init init_nolock(void) { int error; @@ -245,7 +245,7 @@ int __init init_nolock(void) return 0; } -void __exit exit_nolock(void) +static void __exit exit_nolock(void) { gfs_unregister_lockproto(&nolock_ops); } diff --git a/fs/gfs2/lvb.c b/fs/gfs2/lvb.c index 63b815dad8e7a6..9d72872c6f7306 100644 --- a/fs/gfs2/lvb.c +++ b/fs/gfs2/lvb.c @@ -43,6 +43,7 @@ void gfs2_quota_lvb_out(struct gfs2_quota_lvb *qb, char *lvb) str->qb_value = cpu_to_be64(qb->qb_value); } +#if 0 void gfs2_quota_lvb_print(struct gfs2_quota_lvb *qb) { pv(qb, qb_magic, "%u"); @@ -50,4 +51,5 @@ void gfs2_quota_lvb_print(struct gfs2_quota_lvb *qb) pv(qb, qb_warn, "%llu"); pv(qb, qb_value, "%lld"); } +#endif /* 0 */ diff --git a/fs/gfs2/lvb.h b/fs/gfs2/lvb.h index 1b9eb69b95345b..3c4c17405e9acd 100644 --- a/fs/gfs2/lvb.h +++ b/fs/gfs2/lvb.h @@ -14,7 +14,6 @@ void gfs2_quota_lvb_in(struct gfs2_quota_lvb *qb, char *lvb); void gfs2_quota_lvb_out(struct gfs2_quota_lvb *qb, char *lvb); -void gfs2_quota_lvb_print(struct gfs2_quota_lvb *qb); #endif /* __LVB_DOT_H__ */ diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c index acfc944ce13ea2..b11e659bdd9e8e 100644 --- a/fs/gfs2/ondisk.c +++ b/fs/gfs2/ondisk.c @@ -28,7 +28,7 @@ * @count: the number of bytes * */ - +#if 0 static void print_array(char *title, char *buf, int count) { int x; @@ -42,6 +42,7 @@ static void print_array(char *title, char *buf, int count) if (x % 16) printk("\n"); } +#endif /* 0 */ /* * gfs2_xxx_in - read in an xxx struct @@ -72,7 +73,7 @@ void gfs2_inum_out(const struct gfs2_inum *no, char *buf) str->no_addr = cpu_to_be64(no->no_addr); } -void gfs2_inum_print(struct gfs2_inum *no) +static void gfs2_inum_print(struct gfs2_inum *no) { pv(no, no_formal_ino, "%llu"); pv(no, no_addr, "%llu"); @@ -96,7 +97,7 @@ static void gfs2_meta_header_out(struct gfs2_meta_header *mh, char *buf) str->mh_format = cpu_to_be32(mh->mh_format); } -void gfs2_meta_header_print(struct gfs2_meta_header *mh) +static void gfs2_meta_header_print(struct gfs2_meta_header *mh) { pv(mh, mh_magic, "0x%.8X"); pv(mh, mh_type, "%u"); @@ -121,6 +122,7 @@ void gfs2_sb_in(struct gfs2_sb *sb, char *buf) memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN); } +#if 0 void gfs2_sb_print(struct gfs2_sb *sb) { gfs2_meta_header_print(&sb->sb_header); @@ -136,6 +138,7 @@ void gfs2_sb_print(struct gfs2_sb *sb) pv(sb, sb_lockproto, "%s"); pv(sb, sb_locktable, "%s"); } +#endif /* 0 */ void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf) { @@ -149,6 +152,7 @@ void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf) } +#if 0 void gfs2_rindex_out(struct gfs2_rindex *ri, char *buf) { struct gfs2_rindex *str = (struct gfs2_rindex *)buf; @@ -163,6 +167,8 @@ void gfs2_rindex_out(struct gfs2_rindex *ri, char *buf) memset(str->ri_reserved, 0, sizeof(str->ri_reserved)); } +#endif /* 0 */ + void gfs2_rindex_print(struct gfs2_rindex *ri) { pv(ri, ri_addr, "%llu"); @@ -196,6 +202,7 @@ void gfs2_rgrp_out(struct gfs2_rgrp *rg, char *buf) memset(&str->rg_reserved, 0, sizeof(str->rg_reserved)); } +#if 0 void gfs2_rgrp_print(struct gfs2_rgrp *rg) { gfs2_meta_header_print(&rg->rg_header); @@ -205,6 +212,7 @@ void gfs2_rgrp_print(struct gfs2_rgrp *rg) pa(rg, rg_reserved, 36); } +#endif /* 0 */ void gfs2_quota_in(struct gfs2_quota *qu, char *buf) { @@ -215,6 +223,8 @@ void gfs2_quota_in(struct gfs2_quota *qu, char *buf) qu->qu_value = be64_to_cpu(str->qu_value); } +#if 0 + void gfs2_quota_out(struct gfs2_quota *qu, char *buf) { struct gfs2_quota *str = (struct gfs2_quota *)buf; @@ -231,6 +241,8 @@ void gfs2_quota_print(struct gfs2_quota *qu) pv(qu, qu_value, "%lld"); } +#endif /* 0 */ + void gfs2_dinode_in(struct gfs2_dinode *di, char *buf) { struct gfs2_dinode *str = (struct gfs2_dinode *)buf; @@ -327,6 +339,8 @@ void gfs2_dinode_print(struct gfs2_dinode *di) pv(di, di_eattr, "%llu"); } +#if 0 + void gfs2_dirent_print(struct gfs2_dirent *de, char *name) { char buf[GFS2_FNAMESIZE + 1]; @@ -394,6 +408,8 @@ void gfs2_ea_header_print(struct gfs2_ea_header *ea, char *name) printk(KERN_INFO " name = %s\n", buf); } +#endif /* 0 */ + void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf) { struct gfs2_log_header *str = (struct gfs2_log_header *)buf; @@ -406,6 +422,8 @@ void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf) lh->lh_hash = be32_to_cpu(str->lh_hash); } +#if 0 + void gfs2_log_header_print(struct gfs2_log_header *lh) { gfs2_meta_header_print(&lh->lh_header); @@ -427,6 +445,8 @@ void gfs2_log_descriptor_print(struct gfs2_log_descriptor *ld) pa(ld, ld_reserved, 32); } +#endif /* 0 */ + void gfs2_inum_range_in(struct gfs2_inum_range *ir, char *buf) { struct gfs2_inum_range *str = (struct gfs2_inum_range *)buf; @@ -443,11 +463,13 @@ void gfs2_inum_range_out(struct gfs2_inum_range *ir, char *buf) str->ir_length = cpu_to_be64(ir->ir_length); } +#if 0 void gfs2_inum_range_print(struct gfs2_inum_range *ir) { pv(ir, ir_start, "%llu"); pv(ir, ir_length, "%llu"); } +#endif /* 0 */ void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, char *buf) { @@ -467,12 +489,14 @@ void gfs2_statfs_change_out(struct gfs2_statfs_change *sc, char *buf) str->sc_dinodes = cpu_to_be64(sc->sc_dinodes); } +#if 0 void gfs2_statfs_change_print(struct gfs2_statfs_change *sc) { pv(sc, sc_total, "%lld"); pv(sc, sc_free, "%lld"); pv(sc, sc_dinodes, "%lld"); } +#endif /* 0 */ void gfs2_unlinked_tag_in(struct gfs2_unlinked_tag *ut, char *buf) { @@ -491,12 +515,16 @@ void gfs2_unlinked_tag_out(struct gfs2_unlinked_tag *ut, char *buf) str->__pad = 0; } +#if 0 + void gfs2_unlinked_tag_print(struct gfs2_unlinked_tag *ut) { gfs2_inum_print(&ut->ut_inum); pv(ut, ut_flags, "%u"); } +#endif /* 0 */ + void gfs2_quota_change_in(struct gfs2_quota_change *qc, char *buf) { struct gfs2_quota_change *str = (struct gfs2_quota_change *)buf; @@ -506,6 +534,8 @@ void gfs2_quota_change_in(struct gfs2_quota_change *qc, char *buf) qc->qc_id = be32_to_cpu(str->qc_id); } +#if 0 + void gfs2_quota_change_print(struct gfs2_quota_change *qc) { pv(qc, qc_change, "%lld"); @@ -513,5 +543,5 @@ void gfs2_quota_change_print(struct gfs2_quota_change *qc) pv(qc, qc_id, "%u"); } - +#endif /* 0 */ diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 90e32a3dc50d18..942c4c8b9f568e 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -1086,6 +1086,7 @@ int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, uint32_t id) return error; } +#if 0 int gfs2_quota_read(struct gfs2_sbd *sdp, int user, uint32_t id, struct gfs2_quota *q) { @@ -1121,6 +1122,7 @@ int gfs2_quota_read(struct gfs2_sbd *sdp, int user, uint32_t id, return error; } +#endif /* 0 */ int gfs2_quota_init(struct gfs2_sbd *sdp) { diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h index 005529f6895dfa..1baeeb23d23228 100644 --- a/fs/gfs2/quota.h +++ b/fs/gfs2/quota.h @@ -24,8 +24,6 @@ void gfs2_quota_change(struct gfs2_inode *ip, int64_t change, int gfs2_quota_sync(struct gfs2_sbd *sdp); int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, uint32_t id); -int gfs2_quota_read(struct gfs2_sbd *sdp, int user, uint32_t id, - struct gfs2_quota *q); int gfs2_quota_init(struct gfs2_sbd *sdp); void gfs2_quota_scan(struct gfs2_sbd *sdp); diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index f0dbd2d7aadc03..75a8def8d0bc93 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -264,11 +264,6 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) return 0; } -int gfs2_do_upgrade(struct gfs2_sbd *sdp, struct gfs2_glock *sb_gl) -{ - return 0; -} - /** * gfs2_jindex_hold - Grab a lock on the jindex * @sdp: The GFS2 superblock @@ -837,7 +832,8 @@ struct lfcc { * Returns: errno */ -int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, struct gfs2_holder *t_gh) +static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, + struct gfs2_holder *t_gh) { struct gfs2_inode *ip; struct gfs2_holder ji_gh; diff --git a/fs/gfs2/super.h b/fs/gfs2/super.h index 6abb7b5c88284d..175afdde43bb42 100644 --- a/fs/gfs2/super.h +++ b/fs/gfs2/super.h @@ -14,7 +14,6 @@ void gfs2_tune_init(struct gfs2_tune *gt); int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent); int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent); -int gfs2_do_upgrade(struct gfs2_sbd *sdp, struct gfs2_glock *gl_sb); static inline unsigned int gfs2_jindex_size(struct gfs2_sbd *sdp) { @@ -46,7 +45,6 @@ int gfs2_statfs_sync(struct gfs2_sbd *sdp); int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc); int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc); -int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, struct gfs2_holder *t_gh); int gfs2_freeze_fs(struct gfs2_sbd *sdp); void gfs2_unfreeze_fs(struct gfs2_sbd *sdp); diff --git a/include/linux/gfs2_ondisk.h b/include/linux/gfs2_ondisk.h index 3ab40917383f2a..4356e386464399 100644 --- a/include/linux/gfs2_ondisk.h +++ b/include/linux/gfs2_ondisk.h @@ -450,22 +450,8 @@ extern void gfs2_quota_change_in(struct gfs2_quota_change *qc, char *buf); /* Printing functions */ -extern void gfs2_inum_print(struct gfs2_inum *no); -extern void gfs2_meta_header_print(struct gfs2_meta_header *mh); -extern void gfs2_sb_print(struct gfs2_sb *sb); extern void gfs2_rindex_print(struct gfs2_rindex *ri); -extern void gfs2_rgrp_print(struct gfs2_rgrp *rg); -extern void gfs2_quota_print(struct gfs2_quota *qu); extern void gfs2_dinode_print(struct gfs2_dinode *di); -extern void gfs2_dirent_print(struct gfs2_dirent *de, char *name); -extern void gfs2_leaf_print(struct gfs2_leaf *lf); -extern void gfs2_ea_header_print(struct gfs2_ea_header *ea, char *name); -extern void gfs2_log_header_print(struct gfs2_log_header *lh); -extern void gfs2_log_descriptor_print(struct gfs2_log_descriptor *ld); -extern void gfs2_inum_range_print(struct gfs2_inum_range *ir); -extern void gfs2_statfs_change_print(struct gfs2_statfs_change *sc); -extern void gfs2_unlinked_tag_print(struct gfs2_unlinked_tag *ut); -extern void gfs2_quota_change_print(struct gfs2_quota_change *qc); #endif /* __KERNEL__ */ -- cgit 1.2.3-korg From 56409abbf8a9e3754d752d0189f9b9a609ec78de Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Fri, 28 Apr 2006 11:48:45 -0400 Subject: [GFS2] Remove some unused code Remove some of the unused code flagged up by Adrian Bunk. Cc: Adrian Bunk Signed-off-by: Steven Whitehouse --- fs/gfs2/bmap.c | 31 -------- fs/gfs2/eattr.c | 27 ------- fs/gfs2/glock.c | 23 ------ fs/gfs2/lvb.c | 9 --- fs/gfs2/ondisk.c | 225 ------------------------------------------------------- 5 files changed, 315 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index f570d8caef6893..cfe1a428c6681d 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -48,37 +48,6 @@ struct strip_mine { unsigned int sm_height; }; -/** - * @gfs2_unstuffer_sync - Synchronously unstuff a dinode - * @ip: - * @dibh: - * @block: - * @private: - * - * Cheat and use a metadata buffer instead of a data page. - * - * Returns: errno - */ -#if 0 -int gfs2_unstuffer_sync(struct gfs2_inode *ip, struct buffer_head *dibh, - uint64_t block, void *private) -{ - struct buffer_head *bh; - int error; - - bh = gfs2_meta_new(ip->i_gl, block); - - gfs2_buffer_copy_tail(bh, 0, dibh, sizeof(struct gfs2_dinode)); - - set_buffer_dirty(bh); - error = sync_dirty_buffer(bh); - - brelse(bh); - - return error; -} -#endif /* 0 */ - /** * gfs2_unstuff_dinode - Unstuff a dinode when the data has grown too big * @ip: The GFS2 inode to unstuff diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c index d3316cab2be46b..af4f1c3f5929b8 100644 --- a/fs/gfs2/eattr.c +++ b/fs/gfs2/eattr.c @@ -358,33 +358,6 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, return error; } -#if 0 - -static int gfs2_ea_repack_i(struct gfs2_inode *ip) -{ - return -EOPNOTSUPP; -} - -int gfs2_ea_repack(struct gfs2_inode *ip) -{ - struct gfs2_holder gh; - int error; - - error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); - if (error) - return error; - - /* Some sort of permissions checking would be nice */ - - error = gfs2_ea_repack_i(ip); - - gfs2_glock_dq_uninit(&gh); - - return error; -} - -#endif /* 0 */ - struct ea_list { struct gfs2_ea_request *ei_er; unsigned int ei_size; diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 0a5a0e87b0a6ba..4fb8066dc745cc 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1328,29 +1328,6 @@ static void gfs2_glock_prefetch(struct gfs2_glock *gl, unsigned int state, glops->go_xmote_th(gl, state, flags); } -/** - * gfs2_glock_force_drop - Force a glock to be uncached - * @gl: the glock - * - */ -#if 0 -void gfs2_glock_force_drop(struct gfs2_glock *gl) -{ - struct gfs2_holder gh; - - gfs2_holder_init(gl, LM_ST_UNLOCKED, 0, &gh); - set_bit(HIF_DEMOTE, &gh.gh_iflags); - - spin_lock(&gl->gl_spin); - list_add_tail(&gh.gh_list, &gl->gl_waiters2); - run_queue(gl); - spin_unlock(&gl->gl_spin); - - wait_for_completion(&gh.gh_wait); - gfs2_holder_uninit(&gh); -} -#endif /* 0 */ - static void greedy_work(void *data) { struct greedy *gr = data; diff --git a/fs/gfs2/lvb.c b/fs/gfs2/lvb.c index 9d72872c6f7306..47867db92ea1a1 100644 --- a/fs/gfs2/lvb.c +++ b/fs/gfs2/lvb.c @@ -43,13 +43,4 @@ void gfs2_quota_lvb_out(struct gfs2_quota_lvb *qb, char *lvb) str->qb_value = cpu_to_be64(qb->qb_value); } -#if 0 -void gfs2_quota_lvb_print(struct gfs2_quota_lvb *qb) -{ - pv(qb, qb_magic, "%u"); - pv(qb, qb_limit, "%llu"); - pv(qb, qb_warn, "%llu"); - pv(qb, qb_value, "%lld"); -} -#endif /* 0 */ diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c index b11e659bdd9e8e..f6aba3b156c296 100644 --- a/fs/gfs2/ondisk.c +++ b/fs/gfs2/ondisk.c @@ -19,30 +19,6 @@ #define pv(struct, member, fmt) printk(KERN_INFO " "#member" = "fmt"\n", \ struct->member); -#define pa(struct, member, count) print_array(#member, struct->member, count); - -/** - * print_array - Print out an array of bytes - * @title: what to print before the array - * @buf: the array - * @count: the number of bytes - * - */ -#if 0 -static void print_array(char *title, char *buf, int count) -{ - int x; - - printk(KERN_INFO " %s =\n" KERN_INFO, title); - for (x = 0; x < count; x++) { - printk("%.2X ", (unsigned char)buf[x]); - if (x % 16 == 15) - printk("\n" KERN_INFO); - } - if (x % 16) - printk("\n"); -} -#endif /* 0 */ /* * gfs2_xxx_in - read in an xxx struct @@ -122,24 +98,6 @@ void gfs2_sb_in(struct gfs2_sb *sb, char *buf) memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN); } -#if 0 -void gfs2_sb_print(struct gfs2_sb *sb) -{ - gfs2_meta_header_print(&sb->sb_header); - - pv(sb, sb_fs_format, "%u"); - pv(sb, sb_multihost_format, "%u"); - - pv(sb, sb_bsize, "%u"); - pv(sb, sb_bsize_shift, "%u"); - - gfs2_inum_print(&sb->sb_master_dir); - - pv(sb, sb_lockproto, "%s"); - pv(sb, sb_locktable, "%s"); -} -#endif /* 0 */ - void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf) { struct gfs2_rindex *str = (struct gfs2_rindex *)buf; @@ -152,23 +110,6 @@ void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf) } -#if 0 -void gfs2_rindex_out(struct gfs2_rindex *ri, char *buf) -{ - struct gfs2_rindex *str = (struct gfs2_rindex *)buf; - - str->ri_addr = cpu_to_be64(ri->ri_addr); - str->ri_length = cpu_to_be32(ri->ri_length); - str->__pad = 0; - - str->ri_data0 = cpu_to_be64(ri->ri_data0); - str->ri_data = cpu_to_be32(ri->ri_data); - str->ri_bitbytes = cpu_to_be32(ri->ri_bitbytes); - memset(str->ri_reserved, 0, sizeof(str->ri_reserved)); -} - -#endif /* 0 */ - void gfs2_rindex_print(struct gfs2_rindex *ri) { pv(ri, ri_addr, "%llu"); @@ -202,18 +143,6 @@ void gfs2_rgrp_out(struct gfs2_rgrp *rg, char *buf) memset(&str->rg_reserved, 0, sizeof(str->rg_reserved)); } -#if 0 -void gfs2_rgrp_print(struct gfs2_rgrp *rg) -{ - gfs2_meta_header_print(&rg->rg_header); - pv(rg, rg_flags, "%u"); - pv(rg, rg_free, "%u"); - pv(rg, rg_dinodes, "%u"); - - pa(rg, rg_reserved, 36); -} -#endif /* 0 */ - void gfs2_quota_in(struct gfs2_quota *qu, char *buf) { struct gfs2_quota *str = (struct gfs2_quota *)buf; @@ -223,26 +152,6 @@ void gfs2_quota_in(struct gfs2_quota *qu, char *buf) qu->qu_value = be64_to_cpu(str->qu_value); } -#if 0 - -void gfs2_quota_out(struct gfs2_quota *qu, char *buf) -{ - struct gfs2_quota *str = (struct gfs2_quota *)buf; - - str->qu_limit = cpu_to_be64(qu->qu_limit); - str->qu_warn = cpu_to_be64(qu->qu_warn); - str->qu_value = cpu_to_be64(qu->qu_value); -} - -void gfs2_quota_print(struct gfs2_quota *qu) -{ - pv(qu, qu_limit, "%llu"); - pv(qu, qu_warn, "%llu"); - pv(qu, qu_value, "%lld"); -} - -#endif /* 0 */ - void gfs2_dinode_in(struct gfs2_dinode *di, char *buf) { struct gfs2_dinode *str = (struct gfs2_dinode *)buf; @@ -339,77 +248,6 @@ void gfs2_dinode_print(struct gfs2_dinode *di) pv(di, di_eattr, "%llu"); } -#if 0 - -void gfs2_dirent_print(struct gfs2_dirent *de, char *name) -{ - char buf[GFS2_FNAMESIZE + 1]; - - gfs2_inum_print(&de->de_inum); - pv(de, de_hash, "0x%.8X"); - pv(de, de_rec_len, "%u"); - pv(de, de_name_len, "%u"); - pv(de, de_type, "%u"); - - memset(buf, 0, GFS2_FNAMESIZE + 1); - memcpy(buf, name, de->de_name_len); - printk(KERN_INFO " name = %s\n", buf); -} - -void gfs2_leaf_print(struct gfs2_leaf *lf) -{ - gfs2_meta_header_print(&lf->lf_header); - pv(lf, lf_depth, "%u"); - pv(lf, lf_entries, "%u"); - pv(lf, lf_dirent_format, "%u"); - pv(lf, lf_next, "%llu"); - - pa(lf, lf_reserved, 32); -} - -void gfs2_ea_header_in(struct gfs2_ea_header *ea, char *buf) -{ - struct gfs2_ea_header *str = (struct gfs2_ea_header *)buf; - - ea->ea_rec_len = be32_to_cpu(str->ea_rec_len); - ea->ea_data_len = be32_to_cpu(str->ea_data_len); - ea->ea_name_len = str->ea_name_len; - ea->ea_type = str->ea_type; - ea->ea_flags = str->ea_flags; - ea->ea_num_ptrs = str->ea_num_ptrs; -} - -void gfs2_ea_header_out(struct gfs2_ea_header *ea, char *buf) -{ - struct gfs2_ea_header *str = (struct gfs2_ea_header *)buf; - - str->ea_rec_len = cpu_to_be32(ea->ea_rec_len); - str->ea_data_len = cpu_to_be32(ea->ea_data_len); - str->ea_name_len = ea->ea_name_len; - str->ea_type = ea->ea_type; - str->ea_flags = ea->ea_flags; - str->ea_num_ptrs = ea->ea_num_ptrs; - str->__pad = 0; -} - -void gfs2_ea_header_print(struct gfs2_ea_header *ea, char *name) -{ - char buf[GFS2_EA_MAX_NAME_LEN + 1]; - - pv(ea, ea_rec_len, "%u"); - pv(ea, ea_data_len, "%u"); - pv(ea, ea_name_len, "%u"); - pv(ea, ea_type, "%u"); - pv(ea, ea_flags, "%u"); - pv(ea, ea_num_ptrs, "%u"); - - memset(buf, 0, GFS2_EA_MAX_NAME_LEN + 1); - memcpy(buf, name, ea->ea_name_len); - printk(KERN_INFO " name = %s\n", buf); -} - -#endif /* 0 */ - void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf) { struct gfs2_log_header *str = (struct gfs2_log_header *)buf; @@ -422,31 +260,6 @@ void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf) lh->lh_hash = be32_to_cpu(str->lh_hash); } -#if 0 - -void gfs2_log_header_print(struct gfs2_log_header *lh) -{ - gfs2_meta_header_print(&lh->lh_header); - pv(lh, lh_sequence, "%llu"); - pv(lh, lh_flags, "0x%.8X"); - pv(lh, lh_tail, "%u"); - pv(lh, lh_blkno, "%u"); - pv(lh, lh_hash, "0x%.8X"); -} - -void gfs2_log_descriptor_print(struct gfs2_log_descriptor *ld) -{ - gfs2_meta_header_print(&ld->ld_header); - pv(ld, ld_type, "%u"); - pv(ld, ld_length, "%u"); - pv(ld, ld_data1, "%u"); - pv(ld, ld_data2, "%u"); - - pa(ld, ld_reserved, 32); -} - -#endif /* 0 */ - void gfs2_inum_range_in(struct gfs2_inum_range *ir, char *buf) { struct gfs2_inum_range *str = (struct gfs2_inum_range *)buf; @@ -463,14 +276,6 @@ void gfs2_inum_range_out(struct gfs2_inum_range *ir, char *buf) str->ir_length = cpu_to_be64(ir->ir_length); } -#if 0 -void gfs2_inum_range_print(struct gfs2_inum_range *ir) -{ - pv(ir, ir_start, "%llu"); - pv(ir, ir_length, "%llu"); -} -#endif /* 0 */ - void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, char *buf) { struct gfs2_statfs_change *str = (struct gfs2_statfs_change *)buf; @@ -489,15 +294,6 @@ void gfs2_statfs_change_out(struct gfs2_statfs_change *sc, char *buf) str->sc_dinodes = cpu_to_be64(sc->sc_dinodes); } -#if 0 -void gfs2_statfs_change_print(struct gfs2_statfs_change *sc) -{ - pv(sc, sc_total, "%lld"); - pv(sc, sc_free, "%lld"); - pv(sc, sc_dinodes, "%lld"); -} -#endif /* 0 */ - void gfs2_unlinked_tag_in(struct gfs2_unlinked_tag *ut, char *buf) { struct gfs2_unlinked_tag *str = (struct gfs2_unlinked_tag *)buf; @@ -515,16 +311,6 @@ void gfs2_unlinked_tag_out(struct gfs2_unlinked_tag *ut, char *buf) str->__pad = 0; } -#if 0 - -void gfs2_unlinked_tag_print(struct gfs2_unlinked_tag *ut) -{ - gfs2_inum_print(&ut->ut_inum); - pv(ut, ut_flags, "%u"); -} - -#endif /* 0 */ - void gfs2_quota_change_in(struct gfs2_quota_change *qc, char *buf) { struct gfs2_quota_change *str = (struct gfs2_quota_change *)buf; @@ -534,14 +320,3 @@ void gfs2_quota_change_in(struct gfs2_quota_change *qc, char *buf) qc->qc_id = be32_to_cpu(str->qc_id); } -#if 0 - -void gfs2_quota_change_print(struct gfs2_quota_change *qc) -{ - pv(qc, qc_change, "%lld"); - pv(qc, qc_flags, "0x%.8X"); - pv(qc, qc_id, "%u"); -} - -#endif /* 0 */ - -- cgit 1.2.3-korg From fd88de569b802c4a04aaa6ee74667775f4aed8c6 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Fri, 5 May 2006 16:59:11 -0400 Subject: [GFS2] Readpages support This adds readpages support (and also corrects a small bug in the readpage error path at the same time). Hopefully this will improve performance by allowing GFS to submit larger lumps of I/O at a time. In order to simplify the setting of BH_Boundary, it currently gets set when we hit the end of a indirect pointer block. There is always a boundary at this point with the current allocation code. It doesn't get all the boundaries right though, so there is still room for improvement in this. See comments in fs/gfs2/ops_address.c for further information about readpages with GFS2. Signed-off-by: Steven Whitehouse --- fs/gfs2/bmap.c | 170 ++++++++++++++++++++++++++++++++------------------ fs/gfs2/bmap.h | 5 +- fs/gfs2/dir.c | 8 +-- fs/gfs2/glock.c | 2 +- fs/gfs2/inode.c | 5 +- fs/gfs2/log.c | 4 +- fs/gfs2/ops_address.c | 145 +++++++++++++++++++++++++++++++++--------- fs/gfs2/ops_super.c | 3 - fs/gfs2/ops_vm.c | 8 +-- fs/gfs2/quota.c | 5 +- fs/gfs2/recovery.c | 8 +-- fs/gfs2/rgrp.c | 15 ++--- fs/gfs2/unlinked.c | 5 +- 13 files changed, 254 insertions(+), 129 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index cfe1a428c6681d..474b9a16f0f547 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -314,13 +314,17 @@ static void find_metapath(struct gfs2_inode *ip, uint64_t block, * metadata tree. */ -static inline uint64_t *metapointer(struct buffer_head *bh, - unsigned int height, struct metapath *mp) +static inline u64 *metapointer(struct buffer_head *bh, int *boundary, + unsigned int height, const struct metapath *mp) { unsigned int head_size = (height > 0) ? sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_dinode); - - return ((uint64_t *)(bh->b_data + head_size)) + mp->mp_list[height]; + u64 *ptr; + *boundary = 0; + ptr = ((u64 *)(bh->b_data + head_size)) + mp->mp_list[height]; + if (ptr + 1 == (u64*)(bh->b_data + bh->b_size)) + *boundary = 1; + return ptr; } /** @@ -339,24 +343,24 @@ static inline uint64_t *metapointer(struct buffer_head *bh, * */ -static void lookup_block(struct gfs2_inode *ip, struct buffer_head *bh, - unsigned int height, struct metapath *mp, int create, - int *new, uint64_t *block) +static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh, + unsigned int height, struct metapath *mp, int create, + int *new, uint64_t *block) { - uint64_t *ptr = metapointer(bh, height, mp); + int boundary; + uint64_t *ptr = metapointer(bh, &boundary, height, mp); if (*ptr) { *block = be64_to_cpu(*ptr); - return; + return boundary; } *block = 0; if (!create) - return; + return 0; - if (height == ip->i_di.di_height - 1 && - !gfs2_is_dir(ip)) + if (height == ip->i_di.di_height - 1 && !gfs2_is_dir(ip)) *block = gfs2_alloc_data(ip); else *block = gfs2_alloc_meta(ip); @@ -367,15 +371,16 @@ static void lookup_block(struct gfs2_inode *ip, struct buffer_head *bh, ip->i_di.di_blocks++; *new = 1; + return 0; } /** - * gfs2_block_map - Map a block from an inode to a disk block - * @ip: The GFS2 inode + * gfs2_block_pointers - Map a block from an inode to a disk block + * @inode: The inode * @lblock: The logical block number * @new: Value/Result argument (1 = may create/did create new blocks) - * @dblock: the disk block number of the start of an extent - * @extlen: the size of the extent + * @boundary: gets set if we've hit a block boundary + * @mp: metapath to use * * Find the block number on the current device which corresponds to an * inode's block. If the block had to be created, "new" will be set. @@ -383,12 +388,14 @@ static void lookup_block(struct gfs2_inode *ip, struct buffer_head *bh, * Returns: errno */ -int gfs2_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new, - uint64_t *dblock, uint32_t *extlen) +static struct buffer_head *gfs2_block_pointers(struct inode *inode, u64 lblock, + int *new, u64 *dblock, + int *boundary, + struct metapath *mp) { + struct gfs2_inode *ip = inode->u.generic_ip; struct gfs2_sbd *sdp = ip->i_sbd; struct buffer_head *bh; - struct metapath mp; int create = *new; unsigned int bsize; unsigned int height; @@ -398,13 +405,6 @@ int gfs2_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new, *new = 0; *dblock = 0; - if (extlen) - *extlen = 0; - - if (create) - down_write(&ip->i_rw_mutex); - else - down_read(&ip->i_rw_mutex); if (gfs2_assert_warn(sdp, !gfs2_is_stuffed(ip))) goto out; @@ -421,7 +421,7 @@ int gfs2_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new, goto out; } - find_metapath(ip, lblock, &mp); + find_metapath(ip, lblock, mp); end_of_metadata = ip->i_di.di_height - 1; error = gfs2_meta_inode_buffer(ip, &bh); @@ -429,7 +429,7 @@ int gfs2_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new, goto out; for (x = 0; x < end_of_metadata; x++) { - lookup_block(ip, bh, x, &mp, create, new, dblock); + lookup_block(ip, bh, x, mp, create, new, dblock); brelse(bh); if (!*dblock) goto out; @@ -439,49 +439,95 @@ int gfs2_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new, goto out; } - lookup_block(ip, bh, end_of_metadata, &mp, create, new, dblock); - - if (extlen && *dblock) { - *extlen = 1; - - if (!*new) { - uint64_t tmp_dblock; - int tmp_new; - unsigned int nptrs; - - nptrs = (end_of_metadata) ? sdp->sd_inptrs : - sdp->sd_diptrs; - - while (++mp.mp_list[end_of_metadata] < nptrs) { - lookup_block(ip, bh, end_of_metadata, &mp, - 0, &tmp_new, &tmp_dblock); - - if (*dblock + *extlen != tmp_dblock) - break; - - (*extlen)++; - } - } - } - - brelse(bh); - + *boundary = lookup_block(ip, bh, end_of_metadata, mp, create, new, dblock); if (*new) { - error = gfs2_meta_inode_buffer(ip, &bh); + struct buffer_head *dibh; + error = gfs2_meta_inode_buffer(ip, &dibh); if (!error) { - gfs2_trans_add_bh(ip->i_gl, bh, 1); - gfs2_dinode_out(&ip->i_di, bh->b_data); - brelse(bh); + gfs2_trans_add_bh(ip->i_gl, dibh, 1); + gfs2_dinode_out(&ip->i_di, dibh->b_data); + brelse(dibh); } } + return bh; +out: + return ERR_PTR(error); +} - out: + +static inline void bmap_lock(struct inode *inode, int create) +{ + struct gfs2_inode *ip = inode->u.generic_ip; + if (create) + down_write(&ip->i_rw_mutex); + else + down_read(&ip->i_rw_mutex); +} + +static inline void bmap_unlock(struct inode *inode, int create) +{ + struct gfs2_inode *ip = inode->u.generic_ip; if (create) up_write(&ip->i_rw_mutex); else up_read(&ip->i_rw_mutex); +} - return error; +int gfs2_block_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, int *boundary) +{ + struct metapath mp; + struct buffer_head *bh; + int create = *new; + + bmap_lock(inode, create); + bh = gfs2_block_pointers(inode, lblock, new, dblock, boundary, &mp); + bmap_unlock(inode, create); + if (!bh) + return 0; + if (IS_ERR(bh)) + return PTR_ERR(bh); + brelse(bh); + return 0; +} + +int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen) +{ + struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_sbd *sdp = ip->i_sbd; + struct metapath mp; + struct buffer_head *bh; + int boundary; + int create = *new; + + BUG_ON(!extlen); + BUG_ON(!dblock); + BUG_ON(!new); + + bmap_lock(inode, create); + bh = gfs2_block_pointers(inode, lblock, new, dblock, &boundary, &mp); + *extlen = 1; + + if (bh && !IS_ERR(bh) && *dblock && !*new) { + u64 tmp_dblock; + int tmp_new; + unsigned int nptrs; + unsigned end_of_metadata = ip->i_di.di_height - 1; + + nptrs = (end_of_metadata) ? sdp->sd_inptrs : sdp->sd_diptrs; + while (++mp.mp_list[end_of_metadata] < nptrs) { + lookup_block(ip, bh, end_of_metadata, &mp, 0, &tmp_new, &tmp_dblock); + if (*dblock + *extlen != tmp_dblock) + break; + (*extlen)++; + } + } + bmap_unlock(inode, create); + if (!bh) + return 0; + if (IS_ERR(bh)) + return PTR_ERR(bh); + brelse(bh); + return 0; } /** @@ -1053,7 +1099,7 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, uint64_t offset, } for (; lblock < lblock_stop; lblock += extlen) { - error = gfs2_block_map(ip, lblock, &new, &dblock, &extlen); + error = gfs2_extent_map(ip->i_vnode, lblock, &new, &dblock, &extlen); if (error) return error; diff --git a/fs/gfs2/bmap.h b/fs/gfs2/bmap.h index 23fb6589d5e305..bc46c114912017 100644 --- a/fs/gfs2/bmap.h +++ b/fs/gfs2/bmap.h @@ -16,9 +16,8 @@ typedef int (*gfs2_unstuffer_t) (struct gfs2_inode * ip, int gfs2_unstuff_dinode(struct gfs2_inode *ip, gfs2_unstuffer_t unstuffer, void *private); -int gfs2_block_map(struct gfs2_inode *ip, - uint64_t lblock, int *new, - uint64_t *dblock, uint32_t *extlen); +int gfs2_block_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, int *boundary); +int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen); int gfs2_truncatei(struct gfs2_inode *ip, uint64_t size); int gfs2_truncatei_resume(struct gfs2_inode *ip); diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 0404783f39b385..7f8b27e4091684 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -197,8 +197,8 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf, if (!extlen) { new = 1; - error = gfs2_block_map(ip, lblock, &new, &dblock, - &extlen); + error = gfs2_extent_map(ip->i_vnode, lblock, &new, + &dblock, &extlen); if (error) goto fail; error = -EIO; @@ -314,8 +314,8 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, if (!extlen) { new = 0; - error = gfs2_block_map(ip, lblock, &new, &dblock, - &extlen); + error = gfs2_extent_map(ip->i_vnode, lblock, &new, + &dblock, &extlen); if (error) goto fail; } diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 4fb8066dc745cc..9d4ae094fa2d7b 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -2125,7 +2125,7 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait) mutex_lock(&sdp->sd_invalidate_inodes_mutex); invalidate_inodes(sdp->sd_vfs); mutex_unlock(&sdp->sd_invalidate_inodes_mutex); - yield(); + msleep(10); } } diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 9084d6037a0cd2..0817f6ede18886 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1606,9 +1606,8 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh) curtime = get_seconds(); if (curtime - ip->i_di.di_atime >= quantum) { gfs2_glock_dq(gh); - gfs2_holder_reinit(LM_ST_EXCLUSIVE, - gh->gh_flags & ~LM_FLAG_ANY, - gh); + gfs2_holder_reinit(LM_ST_EXCLUSIVE, gh->gh_flags & ~LM_FLAG_ANY, + gh); error = gfs2_glock_nq(gh); if (error) return error; diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 134fc57e21d329..02d31e35f0cab8 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -211,9 +211,9 @@ static uint64_t log_bmap(struct gfs2_sbd *sdp, unsigned int lbn) int new = 0; uint64_t dbn; int error; + int bdy; - error = gfs2_block_map(sdp->sd_jdesc->jd_inode->u.generic_ip, - lbn, &new, &dbn, NULL); + error = gfs2_block_map(sdp->sd_jdesc->jd_inode, lbn, &new, &dbn, &bdy); gfs2_assert_withdraw(sdp, !error && dbn); return dbn; diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index afcc12a00a3c05..d89179b316fe82 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -47,12 +48,12 @@ int gfs2_get_block(struct inode *inode, sector_t lblock, struct buffer_head *bh_result, int create) { - struct gfs2_inode *ip = inode->u.generic_ip; int new = create; uint64_t dblock; int error; + int boundary; - error = gfs2_block_map(ip, lblock, &new, &dblock, NULL); + error = gfs2_block_map(inode, lblock, &new, &dblock, &boundary); if (error) return error; @@ -62,6 +63,8 @@ int gfs2_get_block(struct inode *inode, sector_t lblock, map_bh(bh_result, inode->i_sb, dblock); if (new) set_buffer_new(bh_result); + if (boundary) + set_buffer_boundary(bh_result); return 0; } @@ -83,8 +86,9 @@ static int get_block_noalloc(struct inode *inode, sector_t lblock, int new = 0; uint64_t dblock; int error; + int boundary; - error = gfs2_block_map(ip, lblock, &new, &dblock, NULL); + error = gfs2_block_map(inode, lblock, &new, &dblock, &boundary); if (error) return error; @@ -92,6 +96,8 @@ static int get_block_noalloc(struct inode *inode, sector_t lblock, map_bh(bh_result, inode->i_sb, dblock); else if (gfs2_assert_withdraw(ip->i_sbd, !create)) error = -EIO; + if (boundary) + set_buffer_boundary(bh_result); return error; } @@ -151,6 +157,19 @@ out_ignore: return 0; } +static int zero_readpage(struct page *page) +{ + void *kaddr; + + kaddr = kmap_atomic(page, KM_USER0); + memset(kaddr, 0, PAGE_CACHE_SIZE); + kunmap_atomic(page, KM_USER0); + + SetPageUptodate(page); + + return 0; +} + /** * stuffed_readpage - Fill in a Linux page with stuffed file data * @ip: the inode @@ -165,17 +184,18 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page) void *kaddr; int error; + /* Only the first page of a stuffed file might contain data */ + if (unlikely(page->index)) + return zero_readpage(page); + error = gfs2_meta_inode_buffer(ip, &dibh); if (error) return error; kaddr = kmap_atomic(page, KM_USER0); - memcpy((char *)kaddr, - dibh->b_data + sizeof(struct gfs2_dinode), + memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), ip->i_di.di_size); - memset((char *)kaddr + ip->i_di.di_size, - 0, - PAGE_CACHE_SIZE - ip->i_di.di_size); + memset(kaddr + ip->i_di.di_size, 0, PAGE_CACHE_SIZE - ip->i_di.di_size); kunmap_atomic(page, KM_USER0); brelse(dibh); @@ -185,19 +205,6 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page) return 0; } -static int zero_readpage(struct page *page) -{ - void *kaddr; - - kaddr = kmap_atomic(page, KM_USER0); - memset(kaddr, 0, PAGE_CACHE_SIZE); - kunmap_atomic(page, KM_USER0); - - SetPageUptodate(page); - unlock_page(page); - - return 0; -} /** * gfs2_readpage - readpage with locking @@ -215,19 +222,16 @@ static int gfs2_readpage(struct file *file, struct page *page) struct gfs2_holder gh; int error; - if (file != &gfs2_internal_file_sentinal) { + if (likely(file != &gfs2_internal_file_sentinal)) { gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|GL_AOP, &gh); error = gfs2_glock_nq_m_atime(1, &gh); - if (error) + if (unlikely(error)) goto out_unlock; } if (gfs2_is_stuffed(ip)) { - if (!page->index) { - error = stuffed_readpage(ip, page); - unlock_page(page); - } else - error = zero_readpage(page); + error = stuffed_readpage(ip, page); + unlock_page(page); } else error = mpage_readpage(page, gfs2_get_block); @@ -242,6 +246,90 @@ out: return error; out_unlock: unlock_page(page); + if (file != &gfs2_internal_file_sentinal) + gfs2_holder_uninit(&gh); + goto out; +} + +#define list_to_page(head) (list_entry((head)->prev, struct page, lru)) + +/** + * gfs2_readpages - Read a bunch of pages at once + * + * Some notes: + * 1. This is only for readahead, so we can simply ignore any things + * which are slightly inconvenient (such as locking conflicts between + * the page lock and the glock) and return having done no I/O. Its + * obviously not something we'd want to do on too regular a basis. + * Any I/O we ignore at this time will be done via readpage later. + * 2. We have to handle stuffed files here too. + * 3. mpage_readpages() does most of the heavy lifting in the common case. + * 4. gfs2_get_block() is relied upon to set BH_Boundary in the right places. + * 5. We use LM_FLAG_TRY_1CB here, effectively we then have lock-ahead as + * well as read-ahead. + */ +static int gfs2_readpages(struct file *file, struct address_space *mapping, + struct list_head *pages, unsigned nr_pages) +{ + struct inode *inode = mapping->host; + struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_holder gh; + unsigned page_idx; + int ret; + + if (likely(file != &gfs2_internal_file_sentinal)) { + gfs2_holder_init(ip->i_gl, LM_ST_SHARED, + LM_FLAG_TRY_1CB|GL_ATIME|GL_AOP, &gh); + ret = gfs2_glock_nq_m_atime(1, &gh); + if (ret == GLR_TRYFAILED) + goto out_noerror; + if (unlikely(ret)) + goto out_unlock; + } + + if (gfs2_is_stuffed(ip)) { + struct pagevec lru_pvec; + pagevec_init(&lru_pvec, 0); + for (page_idx = 0; page_idx < nr_pages; page_idx++) { + struct page *page = list_to_page(pages); + list_del(&page->lru); + if (!add_to_page_cache(page, mapping, + page->index, GFP_KERNEL)) { + ret = stuffed_readpage(ip, page); + unlock_page(page); + if (!pagevec_add(&lru_pvec, page)) + __pagevec_lru_add(&lru_pvec); + } + page_cache_release(page); + } + pagevec_lru_add(&lru_pvec); + ret = 0; + } else { + /* What we really want to do .... */ + ret = mpage_readpages(mapping, pages, nr_pages, gfs2_get_block); + } + + if (likely(file != &gfs2_internal_file_sentinal)) { + gfs2_glock_dq_m(1, &gh); + gfs2_holder_uninit(&gh); + } +out: + if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) + ret = -EIO; + return ret; +out_noerror: + ret = 0; +out_unlock: + /* unlock all pages, we can't do any I/O right now */ + for (page_idx = 0; page_idx < nr_pages; page_idx++) { + struct page *page = list_to_page(pages); + list_del(&page->lru); + unlock_page(page); + page_cache_release(page); + } + if (likely(file != &gfs2_internal_file_sentinal)) + gfs2_holder_uninit(&gh); goto out; } @@ -572,6 +660,7 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb, struct address_space_operations gfs2_file_aops = { .writepage = gfs2_writepage, .readpage = gfs2_readpage, + .readpages = gfs2_readpages, .sync_page = block_sync_page, .prepare_write = gfs2_prepare_write, .commit_write = gfs2_commit_write, diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 60bf2563c7b4a4..5910c7b5c846c4 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -92,7 +92,6 @@ static void gfs2_put_super(struct super_block *sb) if (error) gfs2_io_error(sdp); } - /* At this point, we're through modifying the disk */ /* Release stuff */ @@ -125,12 +124,10 @@ static void gfs2_put_super(struct super_block *sb) gfs2_jindex_free(sdp); /* Take apart glock structures and buffer lists */ gfs2_gl_hash_clear(sdp, WAIT); - /* Unmount the locking protocol */ gfs2_lm_unmount(sdp); /* At this point, we're through participating in the lockspace */ - gfs2_sys_fs_del(sdp); vfree(sdp); sb->s_fs_info = NULL; diff --git a/fs/gfs2/ops_vm.c b/fs/gfs2/ops_vm.c index dbc57071e7bb4c..d67248cae9b9ad 100644 --- a/fs/gfs2/ops_vm.c +++ b/fs/gfs2/ops_vm.c @@ -90,8 +90,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page) if (error) goto out_gunlock_q; - gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, - &data_blocks, &ind_blocks); + gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks); al->al_requested = data_blocks + ind_blocks; @@ -99,8 +98,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page) if (error) goto out_gunlock_q; - error = gfs2_trans_begin(sdp, - al->al_rgd->rd_ri.ri_length + + error = gfs2_trans_begin(sdp, al->al_rgd->rd_ri.ri_length + ind_blocks + RES_DINODE + RES_STATFS + RES_QUOTA, 0); if (error) @@ -117,7 +115,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page) unsigned int extlen; int new = 1; - error = gfs2_block_map(ip, lblock, &new, &dblock, &extlen); + error = gfs2_extent_map(ip->i_vnode, lblock, &new, &dblock, &extlen); if (error) goto out_trans; diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 942c4c8b9f568e..d49ff43b3a862b 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -255,6 +255,7 @@ static int bh_get(struct gfs2_quota_data *qd) int new = 0; struct buffer_head *bh; int error; + int boundary; mutex_lock(&sdp->sd_quota_mutex); @@ -266,7 +267,7 @@ static int bh_get(struct gfs2_quota_data *qd) block = qd->qd_slot / sdp->sd_qc_per_block; offset = qd->qd_slot % sdp->sd_qc_per_block;; - error = gfs2_block_map(ip, block, &new, &dblock, NULL); + error = gfs2_block_map(ip->i_vnode, block, &new, &dblock, &boundary); if (error) goto fail; error = gfs2_meta_read(ip->i_gl, dblock, DIO_START | DIO_WAIT, &bh); @@ -1162,7 +1163,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp) if (!extlen) { int new = 0; - error = gfs2_block_map(ip, x, &new, &dblock, &extlen); + error = gfs2_extent_map(ip->i_vnode, x, &new, &dblock, &extlen); if (error) goto fail; } diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index d916817fb6e3c2..87adebea3bc39b 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -40,8 +40,7 @@ int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk, uint32_t extlen; int error; - error = gfs2_block_map(ip, blk, &new, &dblock, - &extlen); + error = gfs2_extent_map(ip->i_vnode, blk, &new, &dblock, &extlen); if (error) return error; if (!dblock) { @@ -378,10 +377,11 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head) uint32_t hash; struct buffer_head *bh; int error; - + int boundary; + lblock = head->lh_blkno; gfs2_replay_incr_blk(sdp, &lblock); - error = gfs2_block_map(ip, lblock, &new, &dblock, NULL); + error = gfs2_block_map(ip->i_vnode, lblock, &new, &dblock, &boundary); if (error) return error; if (!dblock) { diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 4ae55969439693..15c326ce13d110 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -956,8 +956,7 @@ static uint32_t rgblk_search(struct gfs2_rgrpd *rgd, uint32_t goal, search in the first part of our first-searched bit block. */ for (x = 0; x <= length; x++) { if (bi->bi_clone) - blk = gfs2_bitfit(rgd, - bi->bi_clone + bi->bi_offset, + blk = gfs2_bitfit(rgd, bi->bi_clone + bi->bi_offset, bi->bi_len, goal, old_state); else blk = gfs2_bitfit(rgd, @@ -976,12 +975,10 @@ static uint32_t rgblk_search(struct gfs2_rgrpd *rgd, uint32_t goal, blk = 0; gfs2_trans_add_bh(rgd->rd_gl, bi->bi_bh, 1); - gfs2_setbit(rgd, - bi->bi_bh->b_data + bi->bi_offset, + gfs2_setbit(rgd, bi->bi_bh->b_data + bi->bi_offset, bi->bi_len, blk, new_state); if (bi->bi_clone) - gfs2_setbit(rgd, - bi->bi_clone + bi->bi_offset, + gfs2_setbit(rgd, bi->bi_clone + bi->bi_offset, bi->bi_len, blk, new_state); return bi->bi_start * GFS2_NBBY + blk; @@ -1064,8 +1061,7 @@ uint64_t gfs2_alloc_data(struct gfs2_inode *ip) else goal = rgd->rd_last_alloc_data; - blk = rgblk_search(rgd, goal, - GFS2_BLKST_FREE, GFS2_BLKST_USED); + blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED); rgd->rd_last_alloc_data = blk; block = rgd->rd_ri.ri_data0 + blk; @@ -1109,8 +1105,7 @@ uint64_t gfs2_alloc_meta(struct gfs2_inode *ip) else goal = rgd->rd_last_alloc_meta; - blk = rgblk_search(rgd, goal, - GFS2_BLKST_FREE, GFS2_BLKST_USED); + blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED); rgd->rd_last_alloc_meta = blk; block = rgd->rd_ri.ri_data0 + blk; diff --git a/fs/gfs2/unlinked.c b/fs/gfs2/unlinked.c index 24b91c23bc2dc6..0d2314a5252c51 100644 --- a/fs/gfs2/unlinked.c +++ b/fs/gfs2/unlinked.c @@ -35,11 +35,12 @@ static int munge_ondisk(struct gfs2_sbd *sdp, unsigned int slot, int new = 0; struct buffer_head *bh; int error; + int boundary; block = slot / sdp->sd_ut_per_block; offset = slot % sdp->sd_ut_per_block; - error = gfs2_block_map(ip, block, &new, &dblock, NULL); + error = gfs2_block_map(ip->i_vnode, block, &new, &dblock, &boundary); if (error) return error; error = gfs2_meta_read(ip->i_gl, dblock, DIO_START | DIO_WAIT, &bh); @@ -354,7 +355,7 @@ int gfs2_unlinked_init(struct gfs2_sbd *sdp) if (!extlen) { int new = 0; - error = gfs2_block_map(ip, x, &new, &dblock, &extlen); + error = gfs2_extent_map(ip->i_vnode, x, &new, &dblock, &extlen); if (error) goto fail; } -- cgit 1.2.3-korg From bd8968010a9a08e67a0ddb3ddee9feb8882e8c2f Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Thu, 18 May 2006 14:54:58 -0400 Subject: [GFS2] Remove semaphore.h from C files We no longer use semaphores, everything has been converted to mutex or rwsem, so we don't need to include this header any more. Signed-off-by: Steven Whitehouse --- fs/gfs2/acl.c | 1 - fs/gfs2/bmap.c | 1 - fs/gfs2/daemon.c | 1 - fs/gfs2/eaops.c | 1 - fs/gfs2/eattr.c | 1 - fs/gfs2/glock.c | 1 - fs/gfs2/glops.c | 1 - fs/gfs2/inode.c | 1 - fs/gfs2/lm.c | 1 - fs/gfs2/log.c | 1 - fs/gfs2/lops.c | 1 - fs/gfs2/lvb.c | 1 - fs/gfs2/main.c | 1 - fs/gfs2/meta_io.c | 1 - fs/gfs2/mount.c | 1 - fs/gfs2/ondisk.c | 1 - fs/gfs2/ops_address.c | 1 - fs/gfs2/ops_dentry.c | 1 - fs/gfs2/ops_export.c | 1 - fs/gfs2/ops_file.c | 1 - fs/gfs2/ops_fstype.c | 1 - fs/gfs2/ops_inode.c | 1 - fs/gfs2/ops_super.c | 1 - fs/gfs2/ops_vm.c | 1 - fs/gfs2/page.c | 1 - fs/gfs2/quota.c | 1 - fs/gfs2/recovery.c | 1 - fs/gfs2/rgrp.c | 1 - fs/gfs2/super.c | 1 - fs/gfs2/sys.c | 1 - fs/gfs2/trans.c | 1 - fs/gfs2/unlinked.c | 1 - fs/gfs2/util.c | 1 - 33 files changed, 33 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index e9d05fe9435728..d822256c7a53bd 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include "gfs2.h" diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 31c3e92820e4ea..32b1d66e68e16e 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/daemon.c b/fs/gfs2/daemon.c index c2b5d69044c61a..aa4d13002bb45b 100644 --- a/fs/gfs2/daemon.c +++ b/fs/gfs2/daemon.c @@ -15,7 +15,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/eaops.c b/fs/gfs2/eaops.c index 1b376eceb6af52..e5e2565ac29230 100644 --- a/fs/gfs2/eaops.c +++ b/fs/gfs2/eaops.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include "gfs2.h" diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c index af4f1c3f5929b8..3930304bc511ea 100644 --- a/fs/gfs2/eattr.c +++ b/fs/gfs2/eattr.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include "gfs2.h" diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 9d4ae094fa2d7b..2029df4b349f90 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include "gfs2.h" diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index d180c89dd56734..5e8ec6a618242b 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -13,7 +13,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 5bc9542c7fcb9c..d218cbf98aa73e 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -16,7 +16,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/lm.c b/fs/gfs2/lm.c index 06a785e9b58229..600b2bc48ba9e8 100644 --- a/fs/gfs2/lm.c +++ b/fs/gfs2/lm.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 02d31e35f0cab8..0e5e9cf9dd466c 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 4d90eb31149773..22a4f038e3b9eb 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -13,7 +13,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/lvb.c b/fs/gfs2/lvb.c index 47867db92ea1a1..a56b23e0a3f111 100644 --- a/fs/gfs2/lvb.c +++ b/fs/gfs2/lvb.c @@ -13,7 +13,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index c8d17b7ba60b26..b0a4582e78db0c 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c @@ -15,7 +15,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index fe46d563d3c8f2..92c1a3f823d8a3 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -18,7 +18,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/mount.c b/fs/gfs2/mount.c index e90ea7d32f9ec1..7e001356824e14 100644 --- a/fs/gfs2/mount.c +++ b/fs/gfs2/mount.c @@ -13,7 +13,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c index f6aba3b156c296..90d398d2d0478a 100644 --- a/fs/gfs2/ondisk.c +++ b/fs/gfs2/ondisk.c @@ -12,7 +12,6 @@ #include #include #include -#include #include "gfs2.h" #include diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index d89179b316fe82..6d2fc107bbd31c 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -17,7 +17,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c index 9583710760936e..6cbff891063eff 100644 --- a/fs/gfs2/ops_dentry.c +++ b/fs/gfs2/ops_dentry.c @@ -15,7 +15,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index be16c68263d1f0..a90397f2819697 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index cf724800e0e933..00522fc927cdd7 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include "gfs2.h" diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 44c64effc964d9..5899ac33451c46 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -16,7 +16,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index b25ec4c8e56a80..c8aeaafec50f67 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include "gfs2.h" diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 5910c7b5c846c4..3661b2f25b8fb0 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -19,7 +19,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/ops_vm.c b/fs/gfs2/ops_vm.c index d67248cae9b9ad..23161be5db1f94 100644 --- a/fs/gfs2/ops_vm.c +++ b/fs/gfs2/ops_vm.c @@ -15,7 +15,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/page.c b/fs/gfs2/page.c index 495db559416484..bc80247060f403 100644 --- a/fs/gfs2/page.c +++ b/fs/gfs2/page.c @@ -15,7 +15,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index d49ff43b3a862b..adfb8062f5de14 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -45,7 +45,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index 87adebea3bc39b..527544b68a6f9e 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 6d918a7c622272..1b1a2aee8f6ba5 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 75a8def8d0bc93..788dbea45c8706 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index f05ba8f6913285..bbfa9e16abc33a 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include "gfs2.h" diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index 18c606d0712653..a4c414c593517d 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/unlinked.c b/fs/gfs2/unlinked.c index 2824b1665f95fb..9ed0a6b8fc639e 100644 --- a/fs/gfs2/unlinked.c +++ b/fs/gfs2/unlinked.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "gfs2.h" #include "lm_interface.h" diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c index 7cd9e25639c4fa..7c3806c674064c 100644 --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include "gfs2.h" -- cgit 1.2.3-korg From 3a8a9a1034813aa99f5ae3150f652d490c5ff10d Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Thu, 18 May 2006 15:09:15 -0400 Subject: [GFS2] Update copyright date to 2006 Signed-off-by: Steven Whitehouse --- fs/gfs2/acl.c | 2 +- fs/gfs2/acl.h | 2 +- fs/gfs2/bmap.c | 2 +- fs/gfs2/bmap.h | 2 +- fs/gfs2/daemon.c | 2 +- fs/gfs2/daemon.h | 2 +- fs/gfs2/dir.c | 2 +- fs/gfs2/dir.h | 2 +- fs/gfs2/eaops.c | 2 +- fs/gfs2/eaops.h | 2 +- fs/gfs2/eattr.c | 2 +- fs/gfs2/eattr.h | 2 +- fs/gfs2/format.h | 2 +- fs/gfs2/gfs2.h | 2 +- fs/gfs2/glock.c | 2 +- fs/gfs2/glock.h | 2 +- fs/gfs2/glops.c | 2 +- fs/gfs2/glops.h | 2 +- fs/gfs2/incore.h | 2 +- fs/gfs2/inode.c | 2 +- fs/gfs2/inode.h | 2 +- fs/gfs2/lm.c | 2 +- fs/gfs2/lm.h | 2 +- fs/gfs2/lm_interface.h | 2 +- fs/gfs2/locking.c | 2 +- fs/gfs2/log.c | 2 +- fs/gfs2/log.h | 2 +- fs/gfs2/lops.c | 2 +- fs/gfs2/lops.h | 2 +- fs/gfs2/lvb.c | 2 +- fs/gfs2/lvb.h | 2 +- fs/gfs2/main.c | 2 +- fs/gfs2/meta_io.c | 2 +- fs/gfs2/meta_io.h | 2 +- fs/gfs2/mount.c | 2 +- fs/gfs2/mount.h | 2 +- fs/gfs2/ondisk.c | 2 +- fs/gfs2/ops_address.c | 2 +- fs/gfs2/ops_address.h | 2 +- fs/gfs2/ops_dentry.c | 2 +- fs/gfs2/ops_dentry.h | 2 +- fs/gfs2/ops_export.c | 2 +- fs/gfs2/ops_export.h | 2 +- fs/gfs2/ops_file.c | 2 +- fs/gfs2/ops_file.h | 2 +- fs/gfs2/ops_fstype.c | 2 +- fs/gfs2/ops_fstype.h | 2 +- fs/gfs2/ops_inode.c | 2 +- fs/gfs2/ops_inode.h | 2 +- fs/gfs2/ops_super.c | 2 +- fs/gfs2/ops_super.h | 2 +- fs/gfs2/ops_vm.c | 2 +- fs/gfs2/ops_vm.h | 2 +- fs/gfs2/page.c | 2 +- fs/gfs2/page.h | 2 +- fs/gfs2/quota.c | 2 +- fs/gfs2/quota.h | 2 +- fs/gfs2/recovery.c | 2 +- fs/gfs2/recovery.h | 2 +- fs/gfs2/rgrp.c | 2 +- fs/gfs2/rgrp.h | 2 +- fs/gfs2/super.c | 2 +- fs/gfs2/super.h | 2 +- fs/gfs2/sys.c | 2 +- fs/gfs2/sys.h | 2 +- fs/gfs2/trans.c | 2 +- fs/gfs2/trans.h | 2 +- fs/gfs2/unlinked.c | 2 +- fs/gfs2/unlinked.h | 2 +- fs/gfs2/util.c | 2 +- fs/gfs2/util.h | 2 +- 71 files changed, 71 insertions(+), 71 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index d822256c7a53bd..343dbe3e87bbf0 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/acl.h b/fs/gfs2/acl.h index a174b4f6bcc299..067105786eaa82 100644 --- a/fs/gfs2/acl.h +++ b/fs/gfs2/acl.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 32b1d66e68e16e..41abd3f4fc737e 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/bmap.h b/fs/gfs2/bmap.h index bc46c114912017..06ccb2d808ad94 100644 --- a/fs/gfs2/bmap.h +++ b/fs/gfs2/bmap.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/daemon.c b/fs/gfs2/daemon.c index aa4d13002bb45b..9e7b9f296786dd 100644 --- a/fs/gfs2/daemon.c +++ b/fs/gfs2/daemon.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/daemon.h b/fs/gfs2/daemon.h index a27fdeda5fbb69..aa68e7a1b0b764 100644 --- a/fs/gfs2/daemon.h +++ b/fs/gfs2/daemon.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 7f8b27e4091684..6918a58261e29b 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/dir.h b/fs/gfs2/dir.h index d209f1fcb8ac84..173403095eb221 100644 --- a/fs/gfs2/dir.h +++ b/fs/gfs2/dir.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/eaops.c b/fs/gfs2/eaops.c index e5e2565ac29230..85c1dbace88b88 100644 --- a/fs/gfs2/eaops.c +++ b/fs/gfs2/eaops.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/eaops.h b/fs/gfs2/eaops.h index 30ec6a09bfd0ff..3dece17e31166d 100644 --- a/fs/gfs2/eaops.h +++ b/fs/gfs2/eaops.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c index 3930304bc511ea..f5169a42a91989 100644 --- a/fs/gfs2/eattr.c +++ b/fs/gfs2/eattr.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/eattr.h b/fs/gfs2/eattr.h index ffd56686225ba9..19fb1dc4ddc42d 100644 --- a/fs/gfs2/eattr.h +++ b/fs/gfs2/eattr.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/format.h b/fs/gfs2/format.h index c7bf32ce3eca28..239f0c3553fc47 100644 --- a/fs/gfs2/format.h +++ b/fs/gfs2/format.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/gfs2.h b/fs/gfs2/gfs2.h index 57175f70e2bd5a..6edbd551a4c041 100644 --- a/fs/gfs2/gfs2.h +++ b/fs/gfs2/gfs2.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 2029df4b349f90..c041590315384d 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index a36b26585fb83e..9df09c7eeb9522 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 5e8ec6a618242b..e262f22f744e0a 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/glops.h b/fs/gfs2/glops.h index 94f2d264aa6428..5c1e9491024f89 100644 --- a/fs/gfs2/glops.h +++ b/fs/gfs2/glops.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 84dd2f579e62ea..fc4a983e3c8936 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index d218cbf98aa73e..27fbcd9b12f0b5 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h index 13bc4eacac6b0e..5ef21317b2f6d0 100644 --- a/fs/gfs2/inode.h +++ b/fs/gfs2/inode.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/lm.c b/fs/gfs2/lm.c index 600b2bc48ba9e8..f45c0ffd1c3564 100644 --- a/fs/gfs2/lm.c +++ b/fs/gfs2/lm.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/lm.h b/fs/gfs2/lm.h index 4ee5c34434bc6b..e821101d19c0a3 100644 --- a/fs/gfs2/lm.h +++ b/fs/gfs2/lm.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/lm_interface.h b/fs/gfs2/lm_interface.h index 378432f17f272e..9d34bf3df1036e 100644 --- a/fs/gfs2/lm_interface.h +++ b/fs/gfs2/lm_interface.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/locking.c b/fs/gfs2/locking.c index 6a78aacb26af90..183192836e986b 100644 --- a/fs/gfs2/locking.c +++ b/fs/gfs2/locking.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 0e5e9cf9dd466c..2a8b4b71dd1fa1 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h index 84a3e902e84876..8cfd0f1d29f835 100644 --- a/fs/gfs2/log.h +++ b/fs/gfs2/log.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 22a4f038e3b9eb..e4c75a74df5bc5 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/lops.h b/fs/gfs2/lops.h index 0c78d222d6f242..8a1029d3d389a3 100644 --- a/fs/gfs2/lops.h +++ b/fs/gfs2/lops.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/lvb.c b/fs/gfs2/lvb.c index a56b23e0a3f111..e88e9cce14e76d 100644 --- a/fs/gfs2/lvb.c +++ b/fs/gfs2/lvb.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/lvb.h b/fs/gfs2/lvb.h index 3c4c17405e9acd..1b1a8b75219a4c 100644 --- a/fs/gfs2/lvb.h +++ b/fs/gfs2/lvb.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index b0a4582e78db0c..9ce56b5c78039a 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 92c1a3f823d8a3..b9895bbd5feb5a 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/meta_io.h b/fs/gfs2/meta_io.h index d72144d5d72799..23c6a596fd9e5b 100644 --- a/fs/gfs2/meta_io.h +++ b/fs/gfs2/meta_io.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/mount.c b/fs/gfs2/mount.c index 7e001356824e14..0d4b230785af78 100644 --- a/fs/gfs2/mount.c +++ b/fs/gfs2/mount.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/mount.h b/fs/gfs2/mount.h index bc8331cd7b2c4b..2eb14722144f04 100644 --- a/fs/gfs2/mount.h +++ b/fs/gfs2/mount.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c index 90d398d2d0478a..b3bc21a6ba07e8 100644 --- a/fs/gfs2/ondisk.c +++ b/fs/gfs2/ondisk.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 6d2fc107bbd31c..16d3ebd320926c 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_address.h b/fs/gfs2/ops_address.h index f201a059fd91a5..b88adddaffb2e9 100644 --- a/fs/gfs2/ops_address.h +++ b/fs/gfs2/ops_address.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c index 6cbff891063eff..fef415e2068ee0 100644 --- a/fs/gfs2/ops_dentry.c +++ b/fs/gfs2/ops_dentry.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_dentry.h b/fs/gfs2/ops_dentry.h index 94e3ee1701655a..1b6e75c0a4a725 100644 --- a/fs/gfs2/ops_dentry.h +++ b/fs/gfs2/ops_dentry.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index a90397f2819697..a376ead7d0cdd1 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_export.h b/fs/gfs2/ops_export.h index 2f342f3d8755b7..88d58e57f51876 100644 --- a/fs/gfs2/ops_export.h +++ b/fs/gfs2/ops_export.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index 00522fc927cdd7..1e8f602c1e507e 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_file.h b/fs/gfs2/ops_file.h index 192577b411f0ad..a2edce38f5cb51 100644 --- a/fs/gfs2/ops_file.h +++ b/fs/gfs2/ops_file.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 5899ac33451c46..a459820455091b 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_fstype.h b/fs/gfs2/ops_fstype.h index c6452874483d96..622f5760d6b289 100644 --- a/fs/gfs2/ops_fstype.h +++ b/fs/gfs2/ops_fstype.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index c8aeaafec50f67..0c06f92368f2d2 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_inode.h b/fs/gfs2/ops_inode.h index 5fafd87c8d7b37..930aaae913771a 100644 --- a/fs/gfs2/ops_inode.h +++ b/fs/gfs2/ops_inode.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 3661b2f25b8fb0..6fa7b8649f140f 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_super.h b/fs/gfs2/ops_super.h index a41d208dc55805..a15ccc27611317 100644 --- a/fs/gfs2/ops_super.h +++ b/fs/gfs2/ops_super.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_vm.c b/fs/gfs2/ops_vm.c index 23161be5db1f94..263c1fb7bbafeb 100644 --- a/fs/gfs2/ops_vm.c +++ b/fs/gfs2/ops_vm.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/ops_vm.h b/fs/gfs2/ops_vm.h index 54e3a8769cbbc3..077cffcd4085c5 100644 --- a/fs/gfs2/ops_vm.h +++ b/fs/gfs2/ops_vm.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/page.c b/fs/gfs2/page.c index bc80247060f403..cd93644c7d7052 100644 --- a/fs/gfs2/page.c +++ b/fs/gfs2/page.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/page.h b/fs/gfs2/page.h index 346e296420c629..2c853a90ac04fe 100644 --- a/fs/gfs2/page.h +++ b/fs/gfs2/page.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index adfb8062f5de14..f752b01846905f 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h index 1baeeb23d23228..af05492f96447d 100644 --- a/fs/gfs2/quota.h +++ b/fs/gfs2/quota.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index 527544b68a6f9e..c504ac1b831d05 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/recovery.h b/fs/gfs2/recovery.h index 248481189300ce..ac0f1d6ce45647 100644 --- a/fs/gfs2/recovery.h +++ b/fs/gfs2/recovery.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 1b1a2aee8f6ba5..c1c6fa9c0e4b1a 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h index 4c44a191b1c110..d2db3719cc0f17 100644 --- a/fs/gfs2/rgrp.h +++ b/fs/gfs2/rgrp.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 788dbea45c8706..a943a505bc5ab6 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/super.h b/fs/gfs2/super.h index 175afdde43bb42..df2495230402e6 100644 --- a/fs/gfs2/super.h +++ b/fs/gfs2/super.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index bbfa9e16abc33a..d32a2c54daee45 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/sys.h b/fs/gfs2/sys.h index 62c8ed89ab9c64..c46a700e801e7d 100644 --- a/fs/gfs2/sys.h +++ b/fs/gfs2/sys.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index a4c414c593517d..05e0b72d56ff09 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/trans.h b/fs/gfs2/trans.h index 6b5e9e8bf56192..60ef163dd9bb94 100644 --- a/fs/gfs2/trans.h +++ b/fs/gfs2/trans.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/unlinked.c b/fs/gfs2/unlinked.c index 9ed0a6b8fc639e..b92d730020553a 100644 --- a/fs/gfs2/unlinked.c +++ b/fs/gfs2/unlinked.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/unlinked.h b/fs/gfs2/unlinked.h index 51e77f88d74f1e..159cf5ffe47e4e 100644 --- a/fs/gfs2/unlinked.h +++ b/fs/gfs2/unlinked.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c index 7c3806c674064c..0b37d6bcc36e37 100644 --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h index 4532dbab0a2c91..8216d28bd816eb 100644 --- a/fs/gfs2/util.h +++ b/fs/gfs2/util.h @@ -1,6 +1,6 @@ /* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions -- cgit 1.2.3-korg From 320dd101e2d595a03439adb92b319f3af53dd1d0 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Thu, 18 May 2006 16:25:27 -0400 Subject: [GFS2] glock debugging and inode cache changes This adds some extra debugging to glock.c and changes inode.c's deallocation code to call the debugging code at a suitable moment. I'm chasing down a particular bug to do with deallocation at the moment and the code can go again once the bug is fixed. Also this includes the first part of some changes to unify the Linux struct inode and GFS2's struct gfs2_inode. This transformation will happen in small parts over the next short period. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 26 +++++++++++++++++++----- fs/gfs2/glock.h | 1 + fs/gfs2/incore.h | 8 ++++++++ fs/gfs2/inode.c | 58 +++++++++++++++++++---------------------------------- fs/gfs2/main.c | 18 ++++++++++++++++- fs/gfs2/ops_super.c | 24 ++++++++++++++++++++++ 6 files changed, 92 insertions(+), 43 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index c041590315384d..2ef8accf1cbcf1 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -47,6 +47,7 @@ struct greedy { typedef void (*glock_examiner) (struct gfs2_glock * gl); static int gfs2_dump_lockstate(struct gfs2_sbd *sdp); +static int dump_glock(struct gfs2_glock *gl); /** * relaxed_state_ok - is a requested lock compatible with the current lock mode? @@ -290,6 +291,8 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, spin_lock_init(&gl->gl_spin); gl->gl_state = LM_ST_UNLOCKED; + gl->gl_owner = NULL; + gl->gl_ip = 0; INIT_LIST_HEAD(&gl->gl_holders); INIT_LIST_HEAD(&gl->gl_waiters1); INIT_LIST_HEAD(&gl->gl_waiters2); @@ -661,8 +664,11 @@ void gfs2_glmutex_lock(struct gfs2_glock *gl) spin_lock(&gl->gl_spin); if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) list_add_tail(&gh.gh_list, &gl->gl_waiters1); - else + else { + gl->gl_owner = current; + gl->gl_ip = (unsigned long)__builtin_return_address(0); complete(&gh.gh_wait); + } spin_unlock(&gl->gl_spin); wait_for_completion(&gh.gh_wait); @@ -683,6 +689,10 @@ static int gfs2_glmutex_trylock(struct gfs2_glock *gl) spin_lock(&gl->gl_spin); if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) acquired = 0; + else { + gl->gl_owner = current; + gl->gl_ip = (unsigned long)__builtin_return_address(0); + } spin_unlock(&gl->gl_spin); return acquired; @@ -698,6 +708,8 @@ void gfs2_glmutex_unlock(struct gfs2_glock *gl) { spin_lock(&gl->gl_spin); clear_bit(GLF_LOCK, &gl->gl_flags); + gl->gl_owner = NULL; + gl->gl_ip = 0; run_queue(gl); BUG_ON(!spin_is_locked(&gl->gl_spin)); spin_unlock(&gl->gl_spin); @@ -1173,7 +1185,7 @@ int gfs2_glock_nq(struct gfs2_holder *gh) struct gfs2_sbd *sdp = gl->gl_sbd; int error = 0; - restart: +restart: if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) { set_bit(HIF_ABORTED, &gh->gh_iflags); return -EIO; @@ -1196,6 +1208,9 @@ int gfs2_glock_nq(struct gfs2_holder *gh) clear_bit(GLF_PREFETCH, &gl->gl_flags); + if (error == GLR_TRYFAILED && (gh->gh_flags & GL_DUMP)) + dump_glock(gl); + return error; } @@ -2212,9 +2227,8 @@ static int dump_glock(struct gfs2_glock *gl) spin_lock(&gl->gl_spin); - printk(KERN_INFO "Glock (%u, %llu)\n", - gl->gl_name.ln_type, - gl->gl_name.ln_number); + printk(KERN_INFO "Glock (%u, %llu)\n", gl->gl_name.ln_type, + gl->gl_name.ln_number); printk(KERN_INFO " gl_flags ="); for (x = 0; x < 32; x++) if (test_bit(x, &gl->gl_flags)) @@ -2222,6 +2236,8 @@ static int dump_glock(struct gfs2_glock *gl) printk(" \n"); printk(KERN_INFO " gl_ref = %d\n", atomic_read(&gl->gl_ref.refcount)); printk(KERN_INFO " gl_state = %u\n", gl->gl_state); + printk(KERN_INFO " gl_owner = %s\n", gl->gl_owner->comm); + print_symbol(KERN_INFO " gl_ip = %s\n", gl->gl_ip); printk(KERN_INFO " req_gh = %s\n", (gl->gl_req_gh) ? "yes" : "no"); printk(KERN_INFO " req_bh = %s\n", (gl->gl_req_bh) ? "yes" : "no"); printk(KERN_INFO " lvb_count = %d\n", atomic_read(&gl->gl_lvb_count)); diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 9df09c7eeb9522..2e0a2ba92aa026 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -27,6 +27,7 @@ #define GL_SYNC 0x00000800 #define GL_NOCANCEL 0x00001000 #define GL_AOP 0x00004000 +#define GL_DUMP 0x00008000 #define GLR_TRYFAILED 13 #define GLR_CANCELED 14 diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index fc4a983e3c8936..92091d006a02ac 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -183,6 +183,8 @@ struct gfs2_glock { spinlock_t gl_spin; unsigned int gl_state; + struct task_struct *gl_owner; + unsigned long gl_ip; struct list_head gl_holders; struct list_head gl_waiters1; /* HIF_MUTEX */ struct list_head gl_waiters2; /* HIF_DEMOTE, HIF_GREEDY */ @@ -244,6 +246,7 @@ enum { }; struct gfs2_inode { + struct inode i_inode; struct gfs2_inum i_num; atomic_t i_count; @@ -270,6 +273,11 @@ struct gfs2_inode { struct buffer_head *i_cache[GFS2_MAX_META_HEIGHT]; }; +static inline struct gfs2_inode *GFS2_I(struct inode *inode) +{ + return container_of(inode, struct gfs2_inode, i_inode); +} + enum { GFF_DID_DIRECT_ALLOC = 0, }; diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 27fbcd9b12f0b5..c2c7d2b63a577f 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -504,7 +504,7 @@ static int inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul, error = gfs2_glock_nq_num(sdp, ul->ul_ut.ut_inum.no_addr, &gfs2_inode_glops, LM_ST_EXCLUSIVE, - LM_FLAG_TRY_1CB, &i_gh); + LM_FLAG_TRY_1CB|GL_DUMP, &i_gh); switch(error) { case 0: break; @@ -724,9 +724,8 @@ struct inode *gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root, if ((name->len == 1 && memcmp(name->name, ".", 1) == 0) || (name->len == 2 && memcmp(name->name, "..", 2) == 0 && dir == sb->s_root->d_inode)) { - gfs2_inode_hold(dip); - ipp = dip; - goto done; + igrab(dir); + return dir; } error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh); @@ -734,7 +733,7 @@ struct inode *gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root, return ERR_PTR(error); if (!is_root) { - error = gfs2_repermission(dip->i_vnode, MAY_EXEC, NULL); + error = gfs2_repermission(dir, MAY_EXEC, NULL); if (error) goto out; } @@ -756,7 +755,6 @@ struct inode *gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root, out: gfs2_glock_dq_uninit(&d_gh); -done: if (error == -ENOENT) return NULL; if (error == 0) { @@ -1058,7 +1056,6 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, int error; munge_mode_uid_gid(dip, &mode, &uid, &gid); - gfs2_alloc_get(dip); error = gfs2_quota_lock(dip, uid, gid); @@ -1069,19 +1066,14 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, if (error) goto out_quota; - error = gfs2_trans_begin(sdp, RES_DINODE + RES_UNLINKED + - RES_QUOTA, 0); + error = gfs2_trans_begin(sdp, RES_DINODE + RES_UNLINKED + RES_QUOTA, 0); if (error) goto out_quota; ul->ul_ut.ut_flags = 0; error = gfs2_unlinked_ondisk_munge(sdp, ul); - - init_dinode(dip, gl, &ul->ul_ut.ut_inum, - mode, uid, gid); - + init_dinode(dip, gl, &ul->ul_ut.ut_inum, mode, uid, gid); gfs2_quota_change(dip, +1, uid, gid); - gfs2_trans_end(sdp); out_quota: @@ -1089,7 +1081,6 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, out: gfs2_alloc_put(dip); - return error; } @@ -1123,8 +1114,7 @@ static int link_dinode(struct gfs2_inode *dip, struct qstr *name, if (error) goto fail_quota_locks; - error = gfs2_trans_begin(sdp, - sdp->sd_max_dirres + + error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + al->al_rgd->rd_ri.ri_length + 2 * RES_DINODE + RES_UNLINKED + RES_STATFS + RES_QUOTA, 0); @@ -1157,19 +1147,18 @@ static int link_dinode(struct gfs2_inode *dip, struct qstr *name, return 0; - fail_end_trans: +fail_end_trans: gfs2_trans_end(sdp); - fail_ipreserv: +fail_ipreserv: if (dip->i_alloc.al_rgd) gfs2_inplace_release(dip); - fail_quota_locks: +fail_quota_locks: gfs2_quota_unlock(dip); - fail: +fail: gfs2_alloc_put(dip); - return error; } @@ -1226,11 +1215,9 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, if (ul->ul_ut.ut_inum.no_addr < dip->i_num.no_addr) { gfs2_glock_dq(ghs); - error = gfs2_glock_nq_num(sdp, - ul->ul_ut.ut_inum.no_addr, - &gfs2_inode_glops, - LM_ST_EXCLUSIVE, GL_SKIP, - ghs + 1); + error = gfs2_glock_nq_num(sdp, ul->ul_ut.ut_inum.no_addr, + &gfs2_inode_glops, LM_ST_EXCLUSIVE, + GL_SKIP, ghs + 1); if (error) { gfs2_unlinked_put(sdp, ul); return ERR_PTR(error); @@ -1248,11 +1235,9 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, if (error) goto fail_gunlock2; } else { - error = gfs2_glock_nq_num(sdp, - ul->ul_ut.ut_inum.no_addr, - &gfs2_inode_glops, - LM_ST_EXCLUSIVE, GL_SKIP, - ghs + 1); + error = gfs2_glock_nq_num(sdp, ul->ul_ut.ut_inum.no_addr, + &gfs2_inode_glops, LM_ST_EXCLUSIVE, + GL_SKIP, ghs + 1); if (error) goto fail_gunlock; } @@ -1285,18 +1270,17 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, return ERR_PTR(-ENOMEM); return inode; - fail_iput: +fail_iput: gfs2_inode_put(ip); - fail_gunlock2: +fail_gunlock2: gfs2_glock_dq_uninit(ghs + 1); - fail_gunlock: +fail_gunlock: gfs2_glock_dq(ghs); - fail: +fail: gfs2_unlinked_put(sdp, ul); - return ERR_PTR(error); } diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index 9ce56b5c78039a..b24d0b40d965c6 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c @@ -23,6 +23,20 @@ #include "sys.h" #include "util.h" +static void gfs2_init_inode_once(void *foo, kmem_cache_t *cachep, unsigned long flags) +{ + struct gfs2_inode *ip = foo; + if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == + SLAB_CTOR_CONSTRUCTOR) { + inode_init_once(&ip->i_inode); + atomic_set(&ip->i_count, 0); + ip->i_vnode = &ip->i_inode; + spin_lock_init(&ip->i_spin); + init_rwsem(&ip->i_rw_mutex); + memset(ip->i_cache, 0, sizeof(ip->i_cache)); + } +} + /** * init_gfs2_fs - Register GFS2 as a filesystem * @@ -49,7 +63,9 @@ static int __init init_gfs2_fs(void) gfs2_inode_cachep = kmem_cache_create("gfs2_inode", sizeof(struct gfs2_inode), - 0, 0, NULL, NULL); + 0, (SLAB_RECLAIM_ACCOUNT| + SLAB_PANIC|SLAB_MEM_SPREAD), + gfs2_init_inode_once, NULL); if (!gfs2_inode_cachep) goto fail; diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 6fa7b8649f140f..1c17acc946f9bd 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -361,7 +361,31 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) return 0; } +static struct inode *gfs2_alloc_inode(struct super_block *sb) +{ + struct gfs2_sbd *sdp = sb->s_fs_info; + struct gfs2_inode *ip; + + ip = kmem_cache_alloc(gfs2_inode_cachep, GFP_KERNEL); + if (ip) { + ip->i_flags = 0; + ip->i_gl = NULL; + ip->i_sbd = sdp; + ip->i_vnode = &ip->i_inode; + ip->i_greedy = gfs2_tune_get(sdp, gt_greedy_default); + ip->i_last_pfault = jiffies; + } + return &ip->i_inode; +} + +static void gfs2_destroy_inode(struct inode *inode) +{ + kmem_cache_free(gfs2_inode_cachep, inode); +} + struct super_operations gfs2_super_ops = { + .alloc_inode = gfs2_alloc_inode, + .destroy_inode = gfs2_destroy_inode, .write_inode = gfs2_write_inode, .put_super = gfs2_put_super, .write_super = gfs2_write_super, -- cgit 1.2.3-korg From 382066da251132f768380f4852ed5afb72d88f80 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 24 May 2006 10:22:09 -0400 Subject: [GFS2] Casts for printing 64bit numbers Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 5 +++-- fs/gfs2/meta_io.c | 7 ++++--- fs/gfs2/ondisk.c | 24 ++++++++++++------------ fs/gfs2/rgrp.c | 4 ++-- fs/gfs2/util.c | 11 ++++++----- 5 files changed, 27 insertions(+), 24 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 2ef8accf1cbcf1..0603a6de52c9c5 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -2196,7 +2196,8 @@ static int dump_inode(struct gfs2_inode *ip) printk(KERN_INFO " Inode:\n"); printk(KERN_INFO " num = %llu %llu\n", - ip->i_num.no_formal_ino, ip->i_num.no_addr); + (unsigned long long)ip->i_num.no_formal_ino, + (unsigned long long)ip->i_num.no_addr); printk(KERN_INFO " type = %u\n", IF2DT(ip->i_di.di_mode)); printk(KERN_INFO " i_count = %d\n", atomic_read(&ip->i_count)); printk(KERN_INFO " i_flags ="); @@ -2228,7 +2229,7 @@ static int dump_glock(struct gfs2_glock *gl) spin_lock(&gl->gl_spin); printk(KERN_INFO "Glock (%u, %llu)\n", gl->gl_name.ln_type, - gl->gl_name.ln_number); + (unsigned long long)gl->gl_name.ln_number); printk(KERN_INFO " gl_flags ="); for (x = 0; x < 32; x++) if (test_bit(x, &gl->gl_flags)) diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index b9895bbd5feb5a..c78517225f61a7 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -65,7 +65,7 @@ static void stuck_releasepage(struct buffer_head *bh) fs_warn(sdp, "stuck in gfs2_releasepage() %p\n", inode); fs_warn(sdp, "blkno = %llu, bh->b_count = %d\n", - (uint64_t)bh->b_blocknr, atomic_read(&bh->b_count)); + (unsigned long long)bh->b_blocknr, atomic_read(&bh->b_count)); fs_warn(sdp, "pinned = %u\n", buffer_pinned(bh)); fs_warn(sdp, "bh->b_private = %s\n", (bd) ? "!NULL" : "NULL"); @@ -75,7 +75,7 @@ static void stuck_releasepage(struct buffer_head *bh) gl = bd->bd_gl; fs_warn(sdp, "gl = (%u, %llu)\n", - gl->gl_name.ln_type, gl->gl_name.ln_number); + gl->gl_name.ln_type, (unsigned long long)gl->gl_name.ln_number); fs_warn(sdp, "bd_list_tr = %s, bd_le.le_list = %s\n", (list_empty(&bd->bd_list_tr)) ? "no" : "yes", @@ -89,7 +89,8 @@ static void stuck_releasepage(struct buffer_head *bh) return; fs_warn(sdp, "ip = %llu %llu\n", - ip->i_num.no_formal_ino, ip->i_num.no_addr); + (unsigned long long)ip->i_num.no_formal_ino, + (unsigned long long)ip->i_num.no_addr); fs_warn(sdp, "ip->i_count = %d, ip->i_vnode = %s\n", atomic_read(&ip->i_count), (ip->i_vnode) ? "!NULL" : "NULL"); diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c index b3bc21a6ba07e8..be5c86e5787edc 100644 --- a/fs/gfs2/ondisk.c +++ b/fs/gfs2/ondisk.c @@ -50,8 +50,8 @@ void gfs2_inum_out(const struct gfs2_inum *no, char *buf) static void gfs2_inum_print(struct gfs2_inum *no) { - pv(no, no_formal_ino, "%llu"); - pv(no, no_addr, "%llu"); + printk(KERN_INFO " no_formal_ino = %llu\n", (unsigned long long)no->no_formal_ino); + printk(KERN_INFO " no_addr = %llu\n", (unsigned long long)no->no_addr); } static void gfs2_meta_header_in(struct gfs2_meta_header *mh, char *buf) @@ -111,10 +111,10 @@ void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf) void gfs2_rindex_print(struct gfs2_rindex *ri) { - pv(ri, ri_addr, "%llu"); + printk(KERN_INFO " ri_addr = %llu\n", (unsigned long long)ri->ri_addr); pv(ri, ri_length, "%u"); - pv(ri, ri_data0, "%llu"); + printk(KERN_INFO " ri_data0 = %llu\n", (unsigned long long)ri->ri_data0); pv(ri, ri_data, "%u"); pv(ri, ri_bitbytes, "%u"); @@ -226,16 +226,16 @@ void gfs2_dinode_print(struct gfs2_dinode *di) pv(di, di_uid, "%u"); pv(di, di_gid, "%u"); pv(di, di_nlink, "%u"); - pv(di, di_size, "%llu"); - pv(di, di_blocks, "%llu"); - pv(di, di_atime, "%lld"); - pv(di, di_mtime, "%lld"); - pv(di, di_ctime, "%lld"); + printk(KERN_INFO " di_size = %llu\n", (unsigned long long)di->di_size); + printk(KERN_INFO " di_blocks = %llu\n", (unsigned long long)di->di_blocks); + printk(KERN_INFO " di_atime = %lld\n", (long long)di->di_atime); + printk(KERN_INFO " di_mtime = %lld\n", (long long)di->di_mtime); + printk(KERN_INFO " di_ctime = %lld\n", (long long)di->di_ctime); pv(di, di_major, "%u"); pv(di, di_minor, "%u"); - pv(di, di_goal_meta, "%llu"); - pv(di, di_goal_data, "%llu"); + printk(KERN_INFO " di_goal_meta = %llu\n", (unsigned long long)di->di_goal_meta); + printk(KERN_INFO " di_goal_data = %llu\n", (unsigned long long)di->di_goal_data); pv(di, di_flags, "0x%.8X"); pv(di, di_payload_format, "%u"); @@ -244,7 +244,7 @@ void gfs2_dinode_print(struct gfs2_dinode *di) pv(di, di_depth, "%u"); pv(di, di_entries, "%u"); - pv(di, di_eattr, "%llu"); + printk(KERN_INFO " di_eattr = %llu\n", (unsigned long long)di->di_eattr); } void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf) diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index c1c6fa9c0e4b1a..691e6f3ce43b7a 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -1165,7 +1165,7 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, uint64_t bstart, rgd = gfs2_blk2rgrpd(sdp, bstart); if (!rgd) { if (gfs2_consist(sdp)) - fs_err(sdp, "block = %llu\n", bstart); + fs_err(sdp, "block = %llu\n", (unsigned long long)bstart); return NULL; } @@ -1452,7 +1452,7 @@ void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist, rgd = gfs2_blk2rgrpd(sdp, block); if (!rgd) { if (gfs2_consist(sdp)) - fs_err(sdp, "block = %llu\n", block); + fs_err(sdp, "block = %llu\n", (unsigned long long)block); return; } diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c index 0b37d6bcc36e37..88974e9824f7a0 100644 --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c @@ -116,7 +116,8 @@ int gfs2_consist_inode_i(struct gfs2_inode *ip, int cluster_wide, "GFS2: fsid=%s: inode = %llu %llu\n" "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", sdp->sd_fsname, - sdp->sd_fsname, ip->i_num.no_formal_ino, ip->i_num.no_addr, + sdp->sd_fsname, (unsigned long long)ip->i_num.no_formal_ino, + (unsigned long long)ip->i_num.no_addr, sdp->sd_fsname, function, file, line); return rv; } @@ -137,7 +138,7 @@ int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide, "GFS2: fsid=%s: RG = %llu\n" "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", sdp->sd_fsname, - sdp->sd_fsname, rgd->rd_ri.ri_addr, + sdp->sd_fsname, (unsigned long long)rgd->rd_ri.ri_addr, sdp->sd_fsname, function, file, line); return rv; } @@ -158,7 +159,7 @@ int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, "GFS2: fsid=%s: bh = %llu (%s)\n" "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", sdp->sd_fsname, - sdp->sd_fsname, (uint64_t)bh->b_blocknr, type, + sdp->sd_fsname, (unsigned long long)bh->b_blocknr, type, sdp->sd_fsname, function, file, line); return (me) ? -1 : -2; } @@ -179,7 +180,7 @@ int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, "GFS2: fsid=%s: bh = %llu (type: exp=%u, found=%u)\n" "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", sdp->sd_fsname, - sdp->sd_fsname, (uint64_t)bh->b_blocknr, type, t, + sdp->sd_fsname, (unsigned long long)bh->b_blocknr, type, t, sdp->sd_fsname, function, file, line); return (me) ? -1 : -2; } @@ -217,7 +218,7 @@ int gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh, "GFS2: fsid=%s: block = %llu\n" "GFS2: fsid=%s: function = %s, file = %s, line = %u\n", sdp->sd_fsname, - sdp->sd_fsname, (uint64_t)bh->b_blocknr, + sdp->sd_fsname, (unsigned long long)bh->b_blocknr, sdp->sd_fsname, function, file, line); return rv; } -- cgit 1.2.3-korg From feaa7bba026c181ce071d5a4884f7f9dd26207a1 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 14 Jun 2006 15:32:57 -0400 Subject: [GFS2] Fix unlinked file handling This patch fixes the way we have been dealing with unlinked, but still open files. It removes all limits (other than memory for inodes, as per every other filesystem) on numbers of these which we can support on GFS2. It also means that (like other fs) its the responsibility of the last process to close the file to deallocate the storage, rather than the person who did the unlinking. Note that with GFS2, those two events might take place on different nodes. Also there are a number of other changes: o We use the Linux inode subsystem as it was intended to be used, wrt allocating GFS2 inodes o The Linux inode cache is now the point which we use for local enforcement of only holding one copy of the inode in core at once (previous to this we used the glock layer). o We no longer use the unlinked "special" file. We just ignore it completely. This makes unlinking more efficient. o We now use the 4th block allocation state. The previously unused state is used to track unlinked but still open inodes. o gfs2_inoded is no longer needed o Several fields are now no longer needed (and removed) from the in core struct gfs2_inode o Several fields are no longer needed (and removed) from the in core superblock There are a number of future possible optimisations and clean ups which have been made possible by this patch. Signed-off-by: Steven Whitehouse --- fs/gfs2/Makefile | 2 +- fs/gfs2/acl.c | 10 +- fs/gfs2/bmap.c | 44 +-- fs/gfs2/daemon.c | 27 -- fs/gfs2/daemon.h | 1 - fs/gfs2/dir.c | 66 ++-- fs/gfs2/eaops.c | 14 +- fs/gfs2/eattr.c | 70 ++-- fs/gfs2/glock.c | 102 ++---- fs/gfs2/glock.h | 5 +- fs/gfs2/glops.c | 9 +- fs/gfs2/incore.h | 48 +-- fs/gfs2/inode.c | 809 ++++++++++---------------------------------- fs/gfs2/inode.h | 32 +- fs/gfs2/log.c | 3 + fs/gfs2/lops.c | 30 +- fs/gfs2/main.c | 2 - fs/gfs2/meta_io.c | 12 +- fs/gfs2/ondisk.c | 17 - fs/gfs2/ops_address.c | 31 +- fs/gfs2/ops_dentry.c | 6 +- fs/gfs2/ops_export.c | 60 ++-- fs/gfs2/ops_file.c | 42 +-- fs/gfs2/ops_fstype.c | 103 ++---- fs/gfs2/ops_inode.c | 168 ++++----- fs/gfs2/ops_super.c | 112 ++++-- fs/gfs2/ops_vm.c | 12 +- fs/gfs2/page.c | 64 ++-- fs/gfs2/quota.c | 28 +- fs/gfs2/recovery.c | 23 +- fs/gfs2/rgrp.c | 118 ++++--- fs/gfs2/rgrp.h | 1 + fs/gfs2/super.c | 45 +-- fs/gfs2/sys.c | 2 - fs/gfs2/trans.h | 1 - fs/gfs2/unlinked.c | 459 ------------------------- fs/gfs2/unlinked.h | 25 -- fs/gfs2/util.c | 2 +- include/linux/gfs2_ondisk.h | 34 +- 39 files changed, 746 insertions(+), 1893 deletions(-) delete mode 100644 fs/gfs2/unlinked.c delete mode 100644 fs/gfs2/unlinked.h (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/Makefile b/fs/gfs2/Makefile index 9974201aa16c14..0b7977623b805f 100644 --- a/fs/gfs2/Makefile +++ b/fs/gfs2/Makefile @@ -3,7 +3,7 @@ gfs2-y := acl.o bmap.o daemon.o dir.o eaops.o eattr.o glock.o \ glops.o inode.o lm.o log.o lops.o locking.o lvb.o main.o meta_io.o \ mount.o ondisk.o ops_address.o ops_dentry.o ops_export.o ops_file.o \ ops_fstype.o ops_inode.o ops_super.o ops_vm.o page.o quota.o \ - recovery.o rgrp.o super.o sys.o trans.o unlinked.o util.o + recovery.o rgrp.o super.o sys.o trans.o util.o obj-$(CONFIG_GFS2_FS_LOCKING_NOLOCK) += locking/nolock/ obj-$(CONFIG_GFS2_FS_LOCKING_DLM) += locking/dlm/ diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index 343dbe3e87bbf0..9ef4cf2c03dbd0 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c @@ -73,7 +73,7 @@ int gfs2_acl_validate_set(struct gfs2_inode *ip, int access, int gfs2_acl_validate_remove(struct gfs2_inode *ip, int access) { - if (!ip->i_sbd->sd_args.ar_posix_acl) + if (!GFS2_SB(&ip->i_inode)->sd_args.ar_posix_acl) return -EOPNOTSUPP; if (current->fsuid != ip->i_di.di_uid && !capable(CAP_FOWNER)) return -EPERM; @@ -160,7 +160,7 @@ int gfs2_check_acl_locked(struct inode *inode, int mask) struct posix_acl *acl = NULL; int error; - error = acl_get(inode->u.generic_ip, ACL_ACCESS, &acl, NULL, NULL, NULL); + error = acl_get(GFS2_I(inode), ACL_ACCESS, &acl, NULL, NULL, NULL); if (error) return error; @@ -175,7 +175,7 @@ int gfs2_check_acl_locked(struct inode *inode, int mask) int gfs2_check_acl(struct inode *inode, int mask) { - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_holder i_gh; int error; @@ -192,7 +192,7 @@ int gfs2_check_acl(struct inode *inode, int mask) static int munge_mode(struct gfs2_inode *ip, mode_t mode) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head *dibh; int error; @@ -217,7 +217,7 @@ static int munge_mode(struct gfs2_inode *ip, mode_t mode) int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); struct posix_acl *acl = NULL, *clone; struct gfs2_ea_request er; mode_t mode = ip->i_di.di_mode; diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 41abd3f4fc737e..98fa07c2b710ee 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -136,7 +136,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, gfs2_unstuffer_t unstuffer, static unsigned int calc_tree_height(struct gfs2_inode *ip, uint64_t size) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); uint64_t *arr; unsigned int max, height; @@ -169,7 +169,7 @@ static unsigned int calc_tree_height(struct gfs2_inode *ip, uint64_t size) static int build_height(struct inode *inode, unsigned height) { - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); unsigned new_height = height - ip->i_di.di_height; struct buffer_head *dibh; struct buffer_head *blocks[GFS2_MAX_META_HEIGHT]; @@ -283,7 +283,7 @@ static int build_height(struct inode *inode, unsigned height) static void find_metapath(struct gfs2_inode *ip, uint64_t block, struct metapath *mp) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); uint64_t b = block; unsigned int i; @@ -382,8 +382,8 @@ static struct buffer_head *gfs2_block_pointers(struct inode *inode, u64 lblock, int *boundary, struct metapath *mp) { - struct gfs2_inode *ip = inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); struct buffer_head *bh; int create = *new; unsigned int bsize; @@ -446,7 +446,7 @@ out: static inline void bmap_lock(struct inode *inode, int create) { - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); if (create) down_write(&ip->i_rw_mutex); else @@ -455,7 +455,7 @@ static inline void bmap_lock(struct inode *inode, int create) static inline void bmap_unlock(struct inode *inode, int create) { - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); if (create) up_write(&ip->i_rw_mutex); else @@ -481,8 +481,8 @@ int gfs2_block_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, int * int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen) { - struct gfs2_inode *ip = inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); struct metapath mp; struct buffer_head *bh; int boundary; @@ -541,7 +541,7 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh, uint64_t block, int first, block_call_t bc, void *data) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head *bh = NULL; uint64_t *top, *bottom; uint64_t bn; @@ -609,8 +609,8 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, struct buffer_head *bh, uint64_t *top, uint64_t *bottom, unsigned int height, void *data) { - struct strip_mine *sm = (struct strip_mine *)data; - struct gfs2_sbd *sdp = ip->i_sbd; + struct strip_mine *sm = data; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_rgrp_list rlist; uint64_t bn, bstart; uint32_t blen; @@ -756,7 +756,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, static int do_grow(struct gfs2_inode *ip, uint64_t size) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al; struct buffer_head *dibh; unsigned int h; @@ -795,7 +795,7 @@ static int do_grow(struct gfs2_inode *ip, uint64_t size) h = calc_tree_height(ip, size); if (ip->i_di.di_height < h) { down_write(&ip->i_rw_mutex); - error = build_height(ip->i_vnode, h); + error = build_height(&ip->i_inode, h); up_write(&ip->i_rw_mutex); if (error) goto out_end_trans; @@ -830,7 +830,7 @@ static int do_grow(struct gfs2_inode *ip, uint64_t size) static int trunc_start(struct gfs2_inode *ip, uint64_t size) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head *dibh; int journaled = gfs2_is_jdata(ip); int error; @@ -854,7 +854,7 @@ static int trunc_start(struct gfs2_inode *ip, uint64_t size) } else { if (size & (uint64_t)(sdp->sd_sb.sb_bsize - 1)) - error = gfs2_block_truncate_page(ip->i_vnode->i_mapping); + error = gfs2_block_truncate_page(ip->i_inode.i_mapping); if (!error) { ip->i_di.di_size = size; @@ -883,7 +883,7 @@ static int trunc_dealloc(struct gfs2_inode *ip, uint64_t size) if (!size) lblock = 0; else - lblock = (size - 1) >> ip->i_sbd->sd_sb.sb_bsize_shift; + lblock = (size - 1) >> GFS2_SB(&ip->i_inode)->sd_sb.sb_bsize_shift; find_metapath(ip, lblock, &mp); gfs2_alloc_get(ip); @@ -911,7 +911,7 @@ static int trunc_dealloc(struct gfs2_inode *ip, uint64_t size) static int trunc_end(struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head *dibh; int error; @@ -990,7 +990,7 @@ int gfs2_truncatei(struct gfs2_inode *ip, uint64_t size) { int error; - if (gfs2_assert_warn(ip->i_sbd, S_ISREG(ip->i_di.di_mode))) + if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), S_ISREG(ip->i_di.di_mode))) return -EINVAL; if (size > ip->i_di.di_size) @@ -1027,7 +1027,7 @@ int gfs2_file_dealloc(struct gfs2_inode *ip) void gfs2_write_calc_reserv(struct gfs2_inode *ip, unsigned int len, unsigned int *data_blocks, unsigned int *ind_blocks) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); unsigned int tmp; if (gfs2_is_dir(ip)) { @@ -1057,7 +1057,7 @@ void gfs2_write_calc_reserv(struct gfs2_inode *ip, unsigned int len, int gfs2_write_alloc_required(struct gfs2_inode *ip, uint64_t offset, unsigned int len, int *alloc_required) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); uint64_t lblock, lblock_stop, dblock; uint32_t extlen; int new = 0; @@ -1088,7 +1088,7 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, uint64_t offset, } for (; lblock < lblock_stop; lblock += extlen) { - error = gfs2_extent_map(ip->i_vnode, lblock, &new, &dblock, &extlen); + error = gfs2_extent_map(&ip->i_inode, lblock, &new, &dblock, &extlen); if (error) return error; diff --git a/fs/gfs2/daemon.c b/fs/gfs2/daemon.c index 9e7b9f296786dd..1453605c8f32d8 100644 --- a/fs/gfs2/daemon.c +++ b/fs/gfs2/daemon.c @@ -25,7 +25,6 @@ #include "quota.h" #include "recovery.h" #include "super.h" -#include "unlinked.h" #include "util.h" /* This uses schedule_timeout() instead of msleep() because it's good for @@ -195,29 +194,3 @@ int gfs2_quotad(void *data) return 0; } -/** - * gfs2_inoded - Deallocate unlinked inodes - * @sdp: Pointer to GFS2 superblock - * - */ - -int gfs2_inoded(void *data) -{ - struct gfs2_sbd *sdp = data; - unsigned long t; - int error; - - while (!kthread_should_stop()) { - error = gfs2_unlinked_dealloc(sdp); - if (error && - error != -EROFS && - !test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) - fs_err(sdp, "inoded: error = %d\n", error); - - t = gfs2_tune_get(sdp, gt_inoded_secs) * HZ; - schedule_timeout_interruptible(t); - } - - return 0; -} - diff --git a/fs/gfs2/daemon.h b/fs/gfs2/daemon.h index aa68e7a1b0b764..aa93eb6f668e33 100644 --- a/fs/gfs2/daemon.h +++ b/fs/gfs2/daemon.h @@ -15,6 +15,5 @@ int gfs2_glockd(void *data); int gfs2_recoverd(void *data); int gfs2_logd(void *data); int gfs2_quotad(void *data); -int gfs2_inoded(void *data); #endif /* __DAEMON_DOT_H__ */ diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 6918a58261e29b..b0353884dd7d11 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -113,7 +113,7 @@ static int gfs2_dir_get_existing_buffer(struct gfs2_inode *ip, uint64_t block, error = gfs2_meta_read(ip->i_gl, block, DIO_START | DIO_WAIT, &bh); if (error) return error; - if (gfs2_metatype_check(ip->i_sbd, bh, GFS2_METATYPE_JD)) { + if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), bh, GFS2_METATYPE_JD)) { brelse(bh); return -EIO; } @@ -158,7 +158,7 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf, static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf, uint64_t offset, unsigned int size) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head *dibh; uint64_t lblock, dblock; uint32_t extlen = 0; @@ -197,7 +197,7 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf, if (!extlen) { new = 1; - error = gfs2_extent_map(ip->i_vnode, lblock, &new, + error = gfs2_extent_map(&ip->i_inode, lblock, &new, &dblock, &extlen); if (error) goto fail; @@ -277,7 +277,7 @@ static int gfs2_dir_read_stuffed(struct gfs2_inode *ip, char *buf, static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, uint64_t offset, unsigned int size) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); uint64_t lblock, dblock; uint32_t extlen = 0; unsigned int o; @@ -314,7 +314,7 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, if (!extlen) { new = 0; - error = gfs2_extent_map(ip->i_vnode, lblock, &new, + error = gfs2_extent_map(&ip->i_inode, lblock, &new, &dblock, &extlen); if (error) goto fail; @@ -534,7 +534,7 @@ static struct gfs2_dirent *gfs2_dirent_scan(struct inode *inode, } consist_inode: - gfs2_consist_inode(inode->u.generic_ip); + gfs2_consist_inode(GFS2_I(inode)); return ERR_PTR(-EIO); } @@ -556,13 +556,13 @@ static int dirent_first(struct gfs2_inode *dip, struct buffer_head *bh, struct gfs2_meta_header *h = (struct gfs2_meta_header *)bh->b_data; if (be32_to_cpu(h->mh_type) == GFS2_METATYPE_LF) { - if (gfs2_meta_check(dip->i_sbd, bh)) + if (gfs2_meta_check(GFS2_SB(&dip->i_inode), bh)) return -EIO; *dent = (struct gfs2_dirent *)(bh->b_data + sizeof(struct gfs2_leaf)); return IS_LEAF; } else { - if (gfs2_metatype_check(dip->i_sbd, bh, GFS2_METATYPE_DI)) + if (gfs2_metatype_check(GFS2_SB(&dip->i_inode), bh, GFS2_METATYPE_DI)) return -EIO; *dent = (struct gfs2_dirent *)(bh->b_data + sizeof(struct gfs2_dinode)); @@ -674,7 +674,7 @@ static struct gfs2_dirent *gfs2_init_dirent(struct inode *inode, const struct qstr *name, struct buffer_head *bh) { - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_dirent *ndent; unsigned offset = 0, totlen; @@ -707,8 +707,10 @@ static int get_leaf(struct gfs2_inode *dip, uint64_t leaf_no, int error; error = gfs2_meta_read(dip->i_gl, leaf_no, DIO_START | DIO_WAIT, bhp); - if (!error && gfs2_metatype_check(dip->i_sbd, *bhp, GFS2_METATYPE_LF)) + if (!error && gfs2_metatype_check(GFS2_SB(&dip->i_inode), *bhp, GFS2_METATYPE_LF)) { + /* printk(KERN_INFO "block num=%llu\n", leaf_no); */ error = -EIO; + } return error; } @@ -759,7 +761,7 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode, { struct buffer_head *bh; struct gfs2_dirent *dent; - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); int error; if (ip->i_di.di_flags & GFS2_DIF_EXHASH) { @@ -771,7 +773,7 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode, gfs2_consist_inode(ip); return ERR_PTR(-EIO); } - + index = name->hash >> (32 - ip->i_di.di_depth); error = get_first_leaf(ip, index, &bh); if (error) @@ -786,12 +788,14 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode, brelse(bh); if (!ln) break; + error = get_leaf(ip, ln, &bh); } while(!error); return error ? ERR_PTR(error) : NULL; } + error = gfs2_meta_inode_buffer(ip, &bh); if (error) return ERR_PTR(error); @@ -807,7 +811,7 @@ got_dent: static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh, u16 depth) { - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); u64 bn = gfs2_alloc_meta(ip); struct buffer_head *bh = gfs2_meta_new(ip->i_gl, bn); struct gfs2_leaf *leaf; @@ -815,6 +819,7 @@ static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh, struct qstr name = { .name = "", .len = 0, .hash = 0 }; if (!bh) return NULL; + gfs2_trans_add_bh(ip->i_gl, bh, 1); gfs2_metatype_set(bh, GFS2_METATYPE_LF, GFS2_FORMAT_LF); leaf = (struct gfs2_leaf *)bh->b_data; @@ -838,8 +843,8 @@ static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh, static int dir_make_exhash(struct inode *inode) { - struct gfs2_inode *dip = inode->u.generic_ip; - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_inode *dip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); struct gfs2_dirent *dent; struct qstr args; struct buffer_head *bh, *dibh; @@ -874,7 +879,7 @@ static int dir_make_exhash(struct inode *inode) args.len = bh->b_size - sizeof(struct gfs2_dinode) + sizeof(struct gfs2_leaf); args.name = bh->b_data; - dent = gfs2_dirent_scan(dip->i_vnode, bh->b_data, bh->b_size, + dent = gfs2_dirent_scan(&dip->i_inode, bh->b_data, bh->b_size, gfs2_dirent_last, &args, NULL); if (!dent) { brelse(bh); @@ -933,7 +938,7 @@ static int dir_make_exhash(struct inode *inode) static int dir_split_leaf(struct inode *inode, const struct qstr *name) { - struct gfs2_inode *dip = inode->u.generic_ip; + struct gfs2_inode *dip = GFS2_I(inode); struct buffer_head *nbh, *obh, *dibh; struct gfs2_leaf *nleaf, *oleaf; struct gfs2_dirent *dent, *prev = NULL, *next = NULL, *new; @@ -1044,7 +1049,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name) oleaf->lf_depth = nleaf->lf_depth; error = gfs2_meta_inode_buffer(dip, &dibh); - if (!gfs2_assert_withdraw(dip->i_sbd, !error)) { + if (!gfs2_assert_withdraw(GFS2_SB(&dip->i_inode), !error)) { dip->i_di.di_blocks++; gfs2_dinode_out(&dip->i_di, dibh->b_data); brelse(dibh); @@ -1073,7 +1078,7 @@ fail_brelse: static int dir_double_exhash(struct gfs2_inode *dip) { - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); struct buffer_head *dibh; uint32_t hsize; uint64_t *buf; @@ -1268,7 +1273,7 @@ static int gfs2_dir_read_leaf(struct inode *inode, u64 *offset, void *opaque, gfs2_filldir_t filldir, int *copied, unsigned *depth, u64 leaf_no) { - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); struct buffer_head *bh; struct gfs2_leaf *lf; unsigned entries = 0; @@ -1348,8 +1353,8 @@ out: static int dir_e_read(struct inode *inode, uint64_t *offset, void *opaque, gfs2_filldir_t filldir) { - struct gfs2_inode *dip = inode->u.generic_ip; - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_inode *dip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); uint32_t hsize, len = 0; uint32_t ht_offset, lp_offset, ht_offset_cur = -1; uint32_t hash, index; @@ -1407,7 +1412,7 @@ out: int gfs2_dir_read(struct inode *inode, uint64_t *offset, void *opaque, gfs2_filldir_t filldir) { - struct gfs2_inode *dip = inode->u.generic_ip; + struct gfs2_inode *dip = GFS2_I(inode); struct dirent_gather g; const struct gfs2_dirent **darr, *dent; struct buffer_head *dibh; @@ -1490,7 +1495,7 @@ int gfs2_dir_search(struct inode *dir, const struct qstr *name, static int dir_new_leaf(struct inode *inode, const struct qstr *name) { struct buffer_head *bh, *obh; - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_leaf *leaf, *oleaf; int error; u32 index; @@ -1545,7 +1550,7 @@ static int dir_new_leaf(struct inode *inode, const struct qstr *name) int gfs2_dir_add(struct inode *inode, const struct qstr *name, const struct gfs2_inum *inum, unsigned type) { - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); struct buffer_head *bh; struct gfs2_dirent *dent; struct gfs2_leaf *leaf; @@ -1623,7 +1628,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name) /* Returns _either_ the entry (if its first in block) or the previous entry otherwise */ - dent = gfs2_dirent_search(dip->i_vnode, name, gfs2_dirent_prev, &bh); + dent = gfs2_dirent_search(&dip->i_inode, name, gfs2_dirent_prev, &bh); if (!dent) { gfs2_consist_inode(dip); return -EIO; @@ -1659,6 +1664,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name) dip->i_di.di_mtime = dip->i_di.di_ctime = get_seconds(); gfs2_dinode_out(&dip->i_di, bh->b_data); brelse(bh); + mark_inode_dirty(&dip->i_inode); return error; } @@ -1683,7 +1689,7 @@ int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename, struct gfs2_dirent *dent; int error; - dent = gfs2_dirent_search(dip->i_vnode, filename, gfs2_dirent_find, &bh); + dent = gfs2_dirent_search(&dip->i_inode, filename, gfs2_dirent_find, &bh); if (!dent) { gfs2_consist_inode(dip); return -EIO; @@ -1720,7 +1726,7 @@ int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename, static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data) { - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); struct buffer_head *bh; struct gfs2_leaf *leaf; uint32_t hsize, len; @@ -1800,7 +1806,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data) static int leaf_dealloc(struct gfs2_inode *dip, uint32_t index, uint32_t len, uint64_t leaf_no, void *data) { - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); struct gfs2_leaf *tmp_leaf; struct gfs2_rgrp_list rlist; struct buffer_head *bh, *dibh; @@ -1920,7 +1926,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, uint32_t index, uint32_t len, int gfs2_dir_exhash_dealloc(struct gfs2_inode *dip) { - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); struct buffer_head *bh; int error; diff --git a/fs/gfs2/eaops.c b/fs/gfs2/eaops.c index 1c5ac3160b3b32..b7e6a37cab6ecd 100644 --- a/fs/gfs2/eaops.c +++ b/fs/gfs2/eaops.c @@ -58,7 +58,7 @@ unsigned int gfs2_ea_name2type(const char *name, char **truncated_name) static int user_eo_get(struct gfs2_inode *ip, struct gfs2_ea_request *er) { - struct inode *inode = ip->i_vnode; + struct inode *inode = &ip->i_inode; int error = permission(inode, MAY_READ, NULL); if (error) return error; @@ -68,7 +68,7 @@ static int user_eo_get(struct gfs2_inode *ip, struct gfs2_ea_request *er) static int user_eo_set(struct gfs2_inode *ip, struct gfs2_ea_request *er) { - struct inode *inode = ip->i_vnode; + struct inode *inode = &ip->i_inode; if (S_ISREG(inode->i_mode) || (S_ISDIR(inode->i_mode) && !(inode->i_mode & S_ISVTX))) { @@ -83,7 +83,7 @@ static int user_eo_set(struct gfs2_inode *ip, struct gfs2_ea_request *er) static int user_eo_remove(struct gfs2_inode *ip, struct gfs2_ea_request *er) { - struct inode *inode = ip->i_vnode; + struct inode *inode = &ip->i_inode; if (S_ISREG(inode->i_mode) || (S_ISDIR(inode->i_mode) && !(inode->i_mode & S_ISVTX))) { @@ -103,7 +103,7 @@ static int system_eo_get(struct gfs2_inode *ip, struct gfs2_ea_request *er) !capable(CAP_SYS_ADMIN)) return -EPERM; - if (ip->i_sbd->sd_args.ar_posix_acl == 0 && + if (GFS2_SB(&ip->i_inode)->sd_args.ar_posix_acl == 0 && (GFS2_ACL_IS_ACCESS(er->er_name, er->er_name_len) || GFS2_ACL_IS_DEFAULT(er->er_name, er->er_name_len))) return -EOPNOTSUPP; @@ -172,7 +172,7 @@ static int system_eo_remove(struct gfs2_inode *ip, struct gfs2_ea_request *er) static int security_eo_get(struct gfs2_inode *ip, struct gfs2_ea_request *er) { - struct inode *inode = ip->i_vnode; + struct inode *inode = &ip->i_inode; int error = permission(inode, MAY_READ, NULL); if (error) return error; @@ -182,7 +182,7 @@ static int security_eo_get(struct gfs2_inode *ip, struct gfs2_ea_request *er) static int security_eo_set(struct gfs2_inode *ip, struct gfs2_ea_request *er) { - struct inode *inode = ip->i_vnode; + struct inode *inode = &ip->i_inode; int error = permission(inode, MAY_WRITE, NULL); if (error) return error; @@ -192,7 +192,7 @@ static int security_eo_set(struct gfs2_inode *ip, struct gfs2_ea_request *er) static int security_eo_remove(struct gfs2_inode *ip, struct gfs2_ea_request *er) { - struct inode *inode = ip->i_vnode; + struct inode *inode = &ip->i_inode; int error = permission(inode, MAY_WRITE, NULL); if (error) return error; diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c index 2e114c07570707..96736932260f2e 100644 --- a/fs/gfs2/eattr.c +++ b/fs/gfs2/eattr.c @@ -80,7 +80,7 @@ static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh, struct gfs2_ea_header *ea, *prev = NULL; int error = 0; - if (gfs2_metatype_check(ip->i_sbd, bh, GFS2_METATYPE_EA)) + if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), bh, GFS2_METATYPE_EA)) return -EIO; for (ea = GFS2_EA_BH2FIRST(bh);; prev = ea, ea = GFS2_EA2NEXT(ea)) { @@ -128,13 +128,13 @@ static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data) goto out; } - if (gfs2_metatype_check(ip->i_sbd, bh, GFS2_METATYPE_IN)) { + if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), bh, GFS2_METATYPE_IN)) { error = -EIO; goto out; } eablk = (uint64_t *)(bh->b_data + sizeof(struct gfs2_meta_header)); - end = eablk + ip->i_sbd->sd_inptrs; + end = eablk + GFS2_SB(&ip->i_inode)->sd_inptrs; for (; eablk < end; eablk++) { uint64_t bn; @@ -232,7 +232,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, struct gfs2_ea_header *prev, void *private) { int *leave = private; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_rgrpd *rgd; struct gfs2_holder rg_gh; struct buffer_head *dibh; @@ -338,7 +338,7 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, if (error) goto out_alloc; - error = gfs2_rindex_hold(ip->i_sbd, &al->al_ri_gh); + error = gfs2_rindex_hold(GFS2_SB(&ip->i_inode), &al->al_ri_gh); if (error) goto out_quota; @@ -459,7 +459,7 @@ int gfs2_ea_list(struct gfs2_inode *ip, struct gfs2_ea_request *er) static int ea_get_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea, char *data) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head **bh; unsigned int amount = GFS2_EA_DATA_LEN(ea); unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize); @@ -604,7 +604,7 @@ int gfs2_ea_get(struct gfs2_inode *ip, struct gfs2_ea_request *er) static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_ea_header *ea; uint64_t block; @@ -641,7 +641,7 @@ static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp) static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea, struct gfs2_ea_request *er) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); ea->ea_data_len = cpu_to_be32(er->er_data_len); ea->ea_name_len = er->er_name_len; @@ -723,7 +723,7 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er, if (error) goto out_gunlock_q; - error = gfs2_trans_begin(ip->i_sbd, + error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), blks + al->al_rgd->rd_ri.ri_length + RES_DINODE + RES_STATFS + RES_QUOTA, 0); if (error) @@ -736,7 +736,7 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er, error = gfs2_meta_inode_buffer(ip, &dibh); if (!error) { if (er->er_flags & GFS2_ERF_MODE) { - gfs2_assert_withdraw(ip->i_sbd, + gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), (ip->i_di.di_mode & S_IFMT) == (er->er_mode & S_IFMT)); ip->i_di.di_mode = er->er_mode; @@ -748,7 +748,7 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er, } out_end_trans: - gfs2_trans_end(ip->i_sbd); + gfs2_trans_end(GFS2_SB(&ip->i_inode)); out_ipres: gfs2_inplace_release(ip); @@ -790,7 +790,7 @@ static int ea_init_i(struct gfs2_inode *ip, struct gfs2_ea_request *er, static int ea_init(struct gfs2_inode *ip, struct gfs2_ea_request *er) { - unsigned int jbsize = ip->i_sbd->sd_jbsize; + unsigned int jbsize = GFS2_SB(&ip->i_inode)->sd_jbsize; unsigned int blks = 1; if (GFS2_EAREQ_SIZE_STUFFED(er) > jbsize) @@ -830,7 +830,7 @@ static void ea_set_remove_stuffed(struct gfs2_inode *ip, return; } else if (GFS2_EA2NEXT(prev) != ea) { prev = GFS2_EA2NEXT(prev); - gfs2_assert_withdraw(ip->i_sbd, GFS2_EA2NEXT(prev) == ea); + gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), GFS2_EA2NEXT(prev) == ea); } len = GFS2_EA_REC_LEN(prev) + GFS2_EA_REC_LEN(ea); @@ -857,7 +857,7 @@ static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh, struct buffer_head *dibh; int error; - error = gfs2_trans_begin(ip->i_sbd, RES_DINODE + 2 * RES_EATTR, 0); + error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + 2 * RES_EATTR, 0); if (error) return error; @@ -876,7 +876,7 @@ static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh, goto out; if (er->er_flags & GFS2_ERF_MODE) { - gfs2_assert_withdraw(ip->i_sbd, + gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), (ip->i_di.di_mode & S_IFMT) == (er->er_mode & S_IFMT)); ip->i_di.di_mode = er->er_mode; } @@ -885,7 +885,7 @@ static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh, gfs2_dinode_out(&ip->i_di, dibh->b_data); brelse(dibh); out: - gfs2_trans_end(ip->i_sbd); + gfs2_trans_end(GFS2_SB(&ip->i_inode)); return error; } @@ -921,7 +921,7 @@ static int ea_set_simple(struct gfs2_inode *ip, struct buffer_head *bh, int stuffed; int error; - stuffed = ea_calc_size(ip->i_sbd, es->es_er, &size); + stuffed = ea_calc_size(GFS2_SB(&ip->i_inode), es->es_er, &size); if (ea->ea_type == GFS2_EATYPE_UNUSED) { if (GFS2_EA_REC_LEN(ea) < size) @@ -947,7 +947,7 @@ static int ea_set_simple(struct gfs2_inode *ip, struct buffer_head *bh, es->es_bh = bh; es->es_ea = ea; blks = 2 + DIV_ROUND_UP(es->es_er->er_data_len, - ip->i_sbd->sd_jbsize); + GFS2_SB(&ip->i_inode)->sd_jbsize); error = ea_alloc_skeleton(ip, es->es_er, blks, ea_set_simple_alloc, es); @@ -961,7 +961,7 @@ static int ea_set_simple(struct gfs2_inode *ip, struct buffer_head *bh, static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er, void *private) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head *indbh, *newbh; uint64_t *eablk; int error; @@ -1050,8 +1050,8 @@ static int ea_set_i(struct gfs2_inode *ip, struct gfs2_ea_request *er, if (!(ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT)) blks++; - if (GFS2_EAREQ_SIZE_STUFFED(er) > ip->i_sbd->sd_jbsize) - blks += DIV_ROUND_UP(er->er_data_len, ip->i_sbd->sd_jbsize); + if (GFS2_EAREQ_SIZE_STUFFED(er) > GFS2_SB(&ip->i_inode)->sd_jbsize) + blks += DIV_ROUND_UP(er->er_data_len, GFS2_SB(&ip->i_inode)->sd_jbsize); return ea_alloc_skeleton(ip, er, blks, ea_set_block, el); } @@ -1061,7 +1061,7 @@ static int ea_set_remove_unstuffed(struct gfs2_inode *ip, { if (el->el_prev && GFS2_EA2NEXT(el->el_prev) != el->el_ea) { el->el_prev = GFS2_EA2NEXT(el->el_prev); - gfs2_assert_withdraw(ip->i_sbd, + gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), GFS2_EA2NEXT(el->el_prev) == el->el_ea); } @@ -1119,7 +1119,7 @@ int gfs2_ea_set(struct gfs2_inode *ip, struct gfs2_ea_request *er) er->er_data = NULL; er->er_data_len = 0; } - error = ea_check_size(ip->i_sbd, er); + error = ea_check_size(GFS2_SB(&ip->i_inode), er); if (error) return error; @@ -1127,7 +1127,7 @@ int gfs2_ea_set(struct gfs2_inode *ip, struct gfs2_ea_request *er) if (error) return error; - if (IS_IMMUTABLE(ip->i_vnode)) + if (IS_IMMUTABLE(&ip->i_inode)) error = -EPERM; else error = gfs2_ea_ops[er->er_type]->eo_set(ip, er); @@ -1144,7 +1144,7 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el) struct buffer_head *dibh; int error; - error = gfs2_trans_begin(ip->i_sbd, RES_DINODE + RES_EATTR, 0); + error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + RES_EATTR, 0); if (error) return error; @@ -1169,7 +1169,7 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el) brelse(dibh); } - gfs2_trans_end(ip->i_sbd); + gfs2_trans_end(GFS2_SB(&ip->i_inode)); return error; } @@ -1219,7 +1219,7 @@ int gfs2_ea_remove(struct gfs2_inode *ip, struct gfs2_ea_request *er) if (error) return error; - if (IS_IMMUTABLE(ip->i_vnode) || IS_APPEND(ip->i_vnode)) + if (IS_IMMUTABLE(&ip->i_inode) || IS_APPEND(&ip->i_inode)) error = -EPERM; else error = gfs2_ea_ops[er->er_type]->eo_remove(ip, er); @@ -1232,7 +1232,7 @@ int gfs2_ea_remove(struct gfs2_inode *ip, struct gfs2_ea_request *er) static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea, char *data) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head **bh; unsigned int amount = GFS2_EA_DATA_LEN(ea); unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize); @@ -1304,7 +1304,7 @@ int gfs2_ea_acl_chmod(struct gfs2_inode *ip, struct gfs2_ea_location *el, int error; if (GFS2_EA_IS_STUFFED(el->el_ea)) { - error = gfs2_trans_begin(ip->i_sbd, RES_DINODE + RES_EATTR, 0); + error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + RES_EATTR, 0); if (error) return error; @@ -1320,22 +1320,22 @@ int gfs2_ea_acl_chmod(struct gfs2_inode *ip, struct gfs2_ea_location *el, error = gfs2_meta_inode_buffer(ip, &dibh); if (!error) { - error = inode_setattr(ip->i_vnode, attr); - gfs2_assert_warn(ip->i_sbd, !error); + error = inode_setattr(&ip->i_inode, attr); + gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error); gfs2_inode_attr_out(ip); gfs2_trans_add_bh(ip->i_gl, dibh, 1); gfs2_dinode_out(&ip->i_di, dibh->b_data); brelse(dibh); } - gfs2_trans_end(ip->i_sbd); + gfs2_trans_end(GFS2_SB(&ip->i_inode)); return error; } static int ea_dealloc_indirect(struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_rgrp_list rlist; struct buffer_head *indbh, *dibh; uint64_t *eablk, *end; @@ -1456,7 +1456,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip) static int ea_dealloc_block(struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; struct gfs2_rgrpd *rgd; struct buffer_head *dibh; @@ -1518,7 +1518,7 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip) if (error) goto out_alloc; - error = gfs2_rindex_hold(ip->i_sbd, &al->al_ri_gh); + error = gfs2_rindex_hold(GFS2_SB(&ip->i_inode), &al->al_ri_gh); if (error) goto out_quota; diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 0603a6de52c9c5..35bac90878a588 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -654,7 +654,7 @@ static void run_queue(struct gfs2_glock *gl) * Gives caller exclusive access to manipulate a glock structure. */ -void gfs2_glmutex_lock(struct gfs2_glock *gl) +static void gfs2_glmutex_lock(struct gfs2_glock *gl) { struct gfs2_holder gh; @@ -704,7 +704,7 @@ static int gfs2_glmutex_trylock(struct gfs2_glock *gl) * */ -void gfs2_glmutex_unlock(struct gfs2_glock *gl) +static void gfs2_glmutex_unlock(struct gfs2_glock *gl) { spin_lock(&gl->gl_spin); clear_bit(GLF_LOCK, &gl->gl_flags); @@ -726,7 +726,7 @@ static void handle_callback(struct gfs2_glock *gl, unsigned int state) { struct gfs2_holder *gh, *new_gh = NULL; - restart: +restart: spin_lock(&gl->gl_spin); list_for_each_entry(gh, &gl->gl_waiters2, gh_list) { @@ -752,13 +752,27 @@ static void handle_callback(struct gfs2_glock *gl, unsigned int state) goto restart; } - out: +out: spin_unlock(&gl->gl_spin); if (new_gh) gfs2_holder_put(new_gh); } +void gfs2_glock_inode_squish(struct inode *inode) +{ + struct gfs2_holder gh; + struct gfs2_glock *gl = GFS2_I(inode)->i_gl; + gfs2_holder_init(gl, LM_ST_UNLOCKED, 0, &gh); + set_bit(HIF_DEMOTE, &gh.gh_iflags); + spin_lock(&gl->gl_spin); + gfs2_assert(inode->i_sb->s_fs_info, list_empty(&gl->gl_holders)); + list_add_tail(&gh.gh_list, &gl->gl_waiters2); + run_queue(gl); + spin_unlock(&gl->gl_spin); + gfs2_holder_uninit(&gh); +} + /** * state_change - record that the glock is now in a different state * @gl: the glock @@ -1383,8 +1397,7 @@ int gfs2_glock_be_greedy(struct gfs2_glock *gl, unsigned int time) struct greedy *gr; struct gfs2_holder *gh; - if (!time || - gl->gl_sbd->sd_args.ar_localcaching || + if (!time || gl->gl_sbd->sd_args.ar_localcaching || test_and_set_bit(GLF_GREEDY, &gl->gl_flags)) return 1; @@ -1784,43 +1797,6 @@ void gfs2_glock_cb(lm_fsdata_t *fsdata, unsigned int type, void *data) } } -/** - * gfs2_try_toss_inode - try to remove a particular inode struct from cache - * sdp: the filesystem - * inum: the inode number - * - */ - -void gfs2_try_toss_inode(struct gfs2_sbd *sdp, struct gfs2_inum *inum) -{ - struct gfs2_glock *gl; - struct gfs2_inode *ip; - int error; - - error = gfs2_glock_get(sdp, inum->no_addr, &gfs2_inode_glops, - NO_CREATE, &gl); - if (error || !gl) - return; - - if (!gfs2_glmutex_trylock(gl)) - goto out; - - ip = gl->gl_object; - if (!ip) - goto out_unlock; - - if (atomic_read(&ip->i_count)) - goto out_unlock; - - gfs2_inode_destroy(ip, 1); - - out_unlock: - gfs2_glmutex_unlock(gl); - - out: - gfs2_glock_put(gl); -} - /** * gfs2_iopen_go_callback - Try to kick the inode/vnode associated with an * iopen glock from memory @@ -1831,34 +1807,10 @@ void gfs2_try_toss_inode(struct gfs2_sbd *sdp, struct gfs2_inum *inum) void gfs2_iopen_go_callback(struct gfs2_glock *io_gl, unsigned int state) { - struct gfs2_glock *i_gl; if (state != LM_ST_UNLOCKED) return; - - spin_lock(&io_gl->gl_spin); - i_gl = io_gl->gl_object; - if (i_gl) { - gfs2_glock_hold(i_gl); - spin_unlock(&io_gl->gl_spin); - } else { - spin_unlock(&io_gl->gl_spin); - return; - } - - if (gfs2_glmutex_trylock(i_gl)) { - struct gfs2_inode *ip = i_gl->gl_object; - if (ip) { - gfs2_try_toss_vnode(ip); - gfs2_glmutex_unlock(i_gl); - gfs2_glock_schedule_for_reclaim(i_gl); - goto out; - } - gfs2_glmutex_unlock(i_gl); - } - - out: - gfs2_glock_put(i_gl); + /* FIXME: remove this? */ } /** @@ -1935,11 +1887,6 @@ void gfs2_reclaim_glock(struct gfs2_sbd *sdp) atomic_inc(&sdp->sd_reclaimed); if (gfs2_glmutex_trylock(gl)) { - if (gl->gl_ops == &gfs2_inode_glops) { - struct gfs2_inode *ip = gl->gl_object; - if (ip && !atomic_read(&ip->i_count)) - gfs2_inode_destroy(ip, 1); - } if (queue_empty(gl, &gl->gl_holders) && gl->gl_state != LM_ST_UNLOCKED && demote_ok(gl)) @@ -2018,7 +1965,7 @@ static void scan_glock(struct gfs2_glock *gl) if (gfs2_glmutex_trylock(gl)) { if (gl->gl_ops == &gfs2_inode_glops) { struct gfs2_inode *ip = gl->gl_object; - if (ip && !atomic_read(&ip->i_count)) + if (ip) goto out_schedule; } if (queue_empty(gl, &gl->gl_holders) && @@ -2078,11 +2025,6 @@ static void clear_glock(struct gfs2_glock *gl) } if (gfs2_glmutex_trylock(gl)) { - if (gl->gl_ops == &gfs2_inode_glops) { - struct gfs2_inode *ip = gl->gl_object; - if (ip && !atomic_read(&ip->i_count)) - gfs2_inode_destroy(ip, 1); - } if (queue_empty(gl, &gl->gl_holders) && gl->gl_state != LM_ST_UNLOCKED) handle_callback(gl, LM_ST_UNLOCKED); @@ -2199,13 +2141,11 @@ static int dump_inode(struct gfs2_inode *ip) (unsigned long long)ip->i_num.no_formal_ino, (unsigned long long)ip->i_num.no_addr); printk(KERN_INFO " type = %u\n", IF2DT(ip->i_di.di_mode)); - printk(KERN_INFO " i_count = %d\n", atomic_read(&ip->i_count)); printk(KERN_INFO " i_flags ="); for (x = 0; x < 32; x++) if (test_bit(x, &ip->i_flags)) printk(" %u", x); printk(" \n"); - printk(KERN_INFO " vnode = %s\n", (ip->i_vnode) ? "yes" : "no"); error = 0; diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 2e0a2ba92aa026..fdf58db44ae3dc 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -88,9 +88,6 @@ void gfs2_holder_uninit(struct gfs2_holder *gh); void gfs2_glock_xmote_th(struct gfs2_glock *gl, unsigned int state, int flags); void gfs2_glock_drop_th(struct gfs2_glock *gl); -void gfs2_glmutex_lock(struct gfs2_glock *gl); -void gfs2_glmutex_unlock(struct gfs2_glock *gl); - int gfs2_glock_nq(struct gfs2_holder *gh); int gfs2_glock_poll(struct gfs2_holder *gh); int gfs2_glock_wait(struct gfs2_holder *gh); @@ -110,6 +107,7 @@ void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs); void gfs2_glock_prefetch_num(struct gfs2_sbd *sdp, uint64_t number, struct gfs2_glock_operations *glops, unsigned int state, int flags); +void gfs2_glock_inode_squish(struct inode *inode); /** * gfs2_glock_nq_init - intialize a holder and enqueue it on a glock @@ -143,7 +141,6 @@ void gfs2_lvb_unhold(struct gfs2_glock *gl); void gfs2_glock_cb(lm_fsdata_t *fsdata, unsigned int type, void *data); -void gfs2_try_toss_inode(struct gfs2_sbd *sdp, struct gfs2_inum *inum); void gfs2_iopen_go_callback(struct gfs2_glock *gl, unsigned int state); void gfs2_glock_schedule_for_reclaim(struct gfs2_glock *gl); diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index e262f22f744e0a..013bf5f1552f0e 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -129,6 +129,7 @@ static void inode_go_xmote_bh(struct gfs2_glock *gl) static void inode_go_drop_th(struct gfs2_glock *gl) { + printk(KERN_INFO "drop th %p\n", gl->gl_object); gfs2_pte_inval(gl); gfs2_glock_drop_th(gl); } @@ -147,6 +148,7 @@ static void inode_go_sync(struct gfs2_glock *gl, int flags) if (test_bit(GLF_DIRTY, &gl->gl_flags)) { if (meta && data) { + printk(KERN_INFO "sync all\n"); gfs2_page_sync(gl, flags | DIO_START); gfs2_log_flush(gl->gl_sbd, gl); gfs2_meta_sync(gl, flags | DIO_START | DIO_WAIT); @@ -224,6 +226,7 @@ static int inode_go_lock(struct gfs2_holder *gh) return 0; if (ip->i_vn != gl->gl_vn) { + printk(KERN_INFO "refresh inode %p\n", &ip->i_inode); error = gfs2_inode_refresh(ip); if (error) return error; @@ -288,7 +291,7 @@ static void inode_greedy(struct gfs2_glock *gl) spin_unlock(&ip->i_spin); - gfs2_inode_put(ip); + iput(&ip->i_inode); } /** @@ -361,14 +364,14 @@ static void trans_go_xmote_th(struct gfs2_glock *gl, unsigned int state, static void trans_go_xmote_bh(struct gfs2_glock *gl) { struct gfs2_sbd *sdp = gl->gl_sbd; - struct gfs2_inode *ip = sdp->sd_jdesc->jd_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode); struct gfs2_glock *j_gl = ip->i_gl; struct gfs2_log_header head; int error; if (gl->gl_state != LM_ST_UNLOCKED && test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) { - gfs2_meta_cache_flush(sdp->sd_jdesc->jd_inode->u.generic_ip); + gfs2_meta_cache_flush(GFS2_I(sdp->sd_jdesc->jd_inode)); j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA); error = gfs2_find_jhead(sdp->sd_jdesc, &head); diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 8caefec888541f..9a67a5954126cf 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -33,7 +33,6 @@ struct gfs2_inode; struct gfs2_file; struct gfs2_revoke; struct gfs2_revoke_replay; -struct gfs2_unlinked; struct gfs2_quota_data; struct gfs2_log_buf; struct gfs2_trans; @@ -245,16 +244,12 @@ struct gfs2_inode { struct inode i_inode; struct gfs2_inum i_num; - atomic_t i_count; unsigned long i_flags; /* GIF_... */ uint64_t i_vn; - struct gfs2_dinode i_di; - - struct gfs2_glock *i_gl; - struct gfs2_sbd *i_sbd; - struct inode *i_vnode; + struct gfs2_dinode i_di; /* To be replaced by ref to block */ + struct gfs2_glock *i_gl; /* Move into i_gh? */ struct gfs2_holder i_iopen_gh; struct gfs2_holder i_gh; /* for prepare/commit_write only */ struct gfs2_alloc i_alloc; @@ -262,18 +257,27 @@ struct gfs2_inode { spinlock_t i_spin; struct rw_semaphore i_rw_mutex; - unsigned int i_greedy; unsigned long i_last_pfault; struct buffer_head *i_cache[GFS2_MAX_META_HEIGHT]; }; +/* + * Since i_inode is the first element of struct gfs2_inode, + * this is effectively a cast. + */ static inline struct gfs2_inode *GFS2_I(struct inode *inode) { return container_of(inode, struct gfs2_inode, i_inode); } +/* To be removed? */ +static inline struct gfs2_sbd *GFS2_SB(struct inode *inode) +{ + return inode->i_sb->s_fs_info; +} + enum { GFF_DID_DIRECT_ALLOC = 0, }; @@ -295,18 +299,6 @@ struct gfs2_revoke_replay { unsigned int rr_where; }; -enum { - ULF_LOCKED = 0, -}; - -struct gfs2_unlinked { - struct list_head ul_list; - unsigned int ul_count; - struct gfs2_unlinked_tag ul_ut; - unsigned long ul_flags; /* ULF_... */ - unsigned int ul_slot; -}; - enum { QDF_USER = 0, QDF_CHANGE = 1, @@ -436,7 +428,6 @@ struct gfs2_tune { unsigned int gt_recoverd_secs; unsigned int gt_logd_secs; unsigned int gt_quotad_secs; - unsigned int gt_inoded_secs; unsigned int gt_quota_simul_sync; /* Max quotavals to sync at once */ unsigned int gt_quota_warn_period; /* Secs between quota warn msgs */ @@ -495,7 +486,6 @@ struct gfs2_sbd { uint32_t sd_hash_bsize; /* sizeof(exhash block) */ uint32_t sd_hash_bsize_shift; uint32_t sd_hash_ptrs; /* Number of pointers in a hash block */ - uint32_t sd_ut_per_block; uint32_t sd_qc_per_block; uint32_t sd_max_dirres; /* Max blocks needed to add a directory entry */ uint32_t sd_max_height; /* Max height of a file's metadata tree */ @@ -527,7 +517,6 @@ struct gfs2_sbd { struct inode *sd_statfs_inode; struct inode *sd_ir_inode; struct inode *sd_sc_inode; - struct inode *sd_ut_inode; struct inode *sd_qc_inode; struct inode *sd_rindex; struct inode *sd_quota_inode; @@ -569,7 +558,6 @@ struct gfs2_sbd { struct gfs2_holder sd_ir_gh; struct gfs2_holder sd_sc_gh; - struct gfs2_holder sd_ut_gh; struct gfs2_holder sd_qc_gh; /* Daemon stuff */ @@ -578,21 +566,9 @@ struct gfs2_sbd { struct task_struct *sd_recoverd_process; struct task_struct *sd_logd_process; struct task_struct *sd_quotad_process; - struct task_struct *sd_inoded_process; struct task_struct *sd_glockd_process[GFS2_GLOCKD_MAX]; unsigned int sd_glockd_num; - /* Unlinked inode stuff */ - - struct list_head sd_unlinked_list; - atomic_t sd_unlinked_count; - spinlock_t sd_unlinked_spin; - struct mutex sd_unlinked_mutex; - - unsigned int sd_unlinked_slots; - unsigned int sd_unlinked_chunks; - unsigned char **sd_unlinked_bitmap; - /* Quota stuff */ struct list_head sd_quota_list; diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index c2c7d2b63a577f..4e9c42119aed42 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -35,7 +35,6 @@ #include "quota.h" #include "rgrp.h" #include "trans.h" -#include "unlinked.h" #include "util.h" /** @@ -72,7 +71,7 @@ static void inode_attr_in(struct gfs2_inode *ip, struct inode *inode) inode->i_ctime.tv_nsec = 0; inode->i_blksize = PAGE_SIZE; inode->i_blocks = ip->i_di.di_blocks << - (ip->i_sbd->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT); + (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT); if (ip->i_di.di_flags & GFS2_DIF_IMMUTABLE) inode->i_flags |= S_IMMUTABLE; @@ -93,13 +92,8 @@ static void inode_attr_in(struct gfs2_inode *ip, struct inode *inode) void gfs2_inode_attr_in(struct gfs2_inode *ip) { - struct inode *inode; - - inode = gfs2_ip2v_lookup(ip); - if (inode) { - inode_attr_in(ip, inode); - iput(inode); - } + struct inode *inode = &ip->i_inode; + inode_attr_in(ip, inode); } /** @@ -112,9 +106,9 @@ void gfs2_inode_attr_in(struct gfs2_inode *ip) void gfs2_inode_attr_out(struct gfs2_inode *ip) { - struct inode *inode = ip->i_vnode; + struct inode *inode = &ip->i_inode; - gfs2_assert_withdraw(ip->i_sbd, + gfs2_assert_withdraw(GFS2_SB(inode), (ip->i_di.di_mode & S_IFMT) == (inode->i_mode & S_IFMT)); ip->i_di.di_mode = inode->i_mode; ip->i_di.di_uid = inode->i_uid; @@ -124,114 +118,100 @@ void gfs2_inode_attr_out(struct gfs2_inode *ip) ip->i_di.di_ctime = inode->i_ctime.tv_sec; } -/** - * gfs2_ip2v_lookup - Get the struct inode for a struct gfs2_inode - * @ip: the struct gfs2_inode to get the struct inode for - * - * Returns: A VFS inode, or NULL if none - */ +static int iget_test(struct inode *inode, void *opaque) +{ + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_inum *inum = opaque; + + if (ip && ip->i_num.no_addr == inum->no_addr) + return 1; -struct inode *gfs2_ip2v_lookup(struct gfs2_inode *ip) + return 0; +} + +static int iget_set(struct inode *inode, void *opaque) { - struct inode *inode = NULL; + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_inum *inum = opaque; - gfs2_assert_warn(ip->i_sbd, test_bit(GIF_MIN_INIT, &ip->i_flags)); + ip->i_num = *inum; + return 0; +} - spin_lock(&ip->i_spin); - if (ip->i_vnode) - inode = igrab(ip->i_vnode); - spin_unlock(&ip->i_spin); +struct inode *gfs2_ilookup(struct super_block *sb, struct gfs2_inum *inum) +{ + return ilookup5(sb, (unsigned long)inum->no_formal_ino, + iget_test, inum); +} - return inode; +static struct inode *gfs2_iget(struct super_block *sb, struct gfs2_inum *inum) +{ + return iget5_locked(sb, (unsigned long)inum->no_formal_ino, + iget_test, iget_set, inum); } /** - * gfs2_ip2v - Get/Create a struct inode for a struct gfs2_inode - * @ip: the struct gfs2_inode to get the struct inode for + * gfs2_inode_lookup - Lookup an inode + * @sb: The super block + * @inum: The inode number + * @type: The type of the inode * - * Returns: A VFS inode, or NULL if no mem + * Returns: A VFS inode, or an error */ -struct inode *gfs2_ip2v(struct gfs2_inode *ip) +struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum *inum, unsigned int type) { - struct inode *inode, *tmp; - - inode = gfs2_ip2v_lookup(ip); - if (inode) - return inode; - - tmp = new_inode(ip->i_sbd->sd_vfs); - if (!tmp) - return NULL; - - inode_attr_in(ip, tmp); - - if (S_ISREG(ip->i_di.di_mode)) { - tmp->i_op = &gfs2_file_iops; - tmp->i_fop = &gfs2_file_fops; - tmp->i_mapping->a_ops = &gfs2_file_aops; - } else if (S_ISDIR(ip->i_di.di_mode)) { - tmp->i_op = &gfs2_dir_iops; - tmp->i_fop = &gfs2_dir_fops; - } else if (S_ISLNK(ip->i_di.di_mode)) { - tmp->i_op = &gfs2_symlink_iops; - } else { - tmp->i_op = &gfs2_dev_iops; - init_special_inode(tmp, tmp->i_mode, tmp->i_rdev); - } - - tmp->u.generic_ip = NULL; - - for (;;) { - spin_lock(&ip->i_spin); - if (!ip->i_vnode) - break; - inode = igrab(ip->i_vnode); - spin_unlock(&ip->i_spin); + struct inode *inode = gfs2_iget(sb, inum); + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_glock *io_gl; + int error; - if (inode) { - iput(tmp); - return inode; + if (inode->i_state & I_NEW) { + struct gfs2_sbd *sdp = GFS2_SB(inode); + umode_t mode = DT2IF(type); + inode->u.generic_ip = ip; + inode->i_mode = mode; + + if (S_ISREG(mode)) { + inode->i_op = &gfs2_file_iops; + inode->i_fop = &gfs2_file_fops; + inode->i_mapping->a_ops = &gfs2_file_aops; + } else if (S_ISDIR(mode)) { + inode->i_op = &gfs2_dir_iops; + inode->i_fop = &gfs2_dir_fops; + } else if (S_ISLNK(mode)) { + inode->i_op = &gfs2_symlink_iops; + } else { + inode->i_op = &gfs2_dev_iops; } - yield(); - } - inode = tmp; + error = gfs2_glock_get(sdp, inum->no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl); + if (unlikely(error)) + goto fail; + ip->i_gl->gl_object = ip; - gfs2_inode_hold(ip); - ip->i_vnode = inode; - inode->u.generic_ip = ip; + error = gfs2_glock_get(sdp, inum->no_addr, &gfs2_iopen_glops, CREATE, &io_gl); + if (unlikely(error)) + goto fail_put; - spin_unlock(&ip->i_spin); + ip->i_vn = ip->i_gl->gl_vn - 1; + error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh); + if (unlikely(error)) + goto fail_iopen; - insert_inode_hash(inode); + gfs2_glock_put(io_gl); + unlock_new_inode(inode); + } return inode; -} - -static int iget_test(struct inode *inode, void *opaque) -{ - struct gfs2_inode *ip = inode->u.generic_ip; - struct gfs2_inum *inum = (struct gfs2_inum *)opaque; - - if (ip && ip->i_num.no_addr == inum->no_addr) - return 1; - - return 0; -} - -struct inode *gfs2_iget(struct super_block *sb, struct gfs2_inum *inum) -{ - return ilookup5(sb, (unsigned long)inum->no_formal_ino, - iget_test, inum); -} - -void gfs2_inode_min_init(struct gfs2_inode *ip, unsigned int type) -{ - if (!test_and_set_bit(GIF_MIN_INIT, &ip->i_flags)) { - ip->i_di.di_nlink = 1; - ip->i_di.di_mode = DT2IF(type); - } +fail_iopen: + gfs2_glock_put(io_gl); +fail_put: + ip->i_gl->gl_object = NULL; + gfs2_glock_put(ip->i_gl); +fail: + iput(inode); + return ERR_PTR(error); } /** @@ -250,7 +230,7 @@ int gfs2_inode_refresh(struct gfs2_inode *ip) if (error) return error; - if (gfs2_metatype_check(ip->i_sbd, dibh, GFS2_METATYPE_DI)) { + if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), dibh, GFS2_METATYPE_DI)) { brelse(dibh); return -EIO; } @@ -273,151 +253,9 @@ int gfs2_inode_refresh(struct gfs2_inode *ip) return 0; } -/** - * inode_create - create a struct gfs2_inode - * @i_gl: The glock covering the inode - * @inum: The inode number - * @io_gl: the iopen glock to acquire/hold (using holder in new gfs2_inode) - * @io_state: the state the iopen glock should be acquired in - * @ipp: pointer to put the returned inode in - * - * Returns: errno - */ - -static int inode_create(struct gfs2_glock *i_gl, const struct gfs2_inum *inum, - struct gfs2_glock *io_gl, unsigned int io_state, - struct gfs2_inode **ipp, int need_lock) +int gfs2_dinode_dealloc(struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = i_gl->gl_sbd; - struct gfs2_inode *ip; - int error = 0; - - ip = kmem_cache_alloc(gfs2_inode_cachep, GFP_KERNEL); - if (!ip) - return -ENOMEM; - memset(ip, 0, sizeof(struct gfs2_inode)); - ip->i_num = *inum; - atomic_set(&ip->i_count, 1); - ip->i_vn = i_gl->gl_vn - 1; - ip->i_gl = i_gl; - ip->i_sbd = sdp; - spin_lock_init(&ip->i_spin); - init_rwsem(&ip->i_rw_mutex); - ip->i_greedy = gfs2_tune_get(sdp, gt_greedy_default); - - if (need_lock) { - error = gfs2_glock_nq_init(io_gl, - io_state, GL_LOCAL_EXCL | GL_EXACT, - &ip->i_iopen_gh); - if (error) - goto fail; - - spin_lock(&io_gl->gl_spin); - gfs2_glock_hold(i_gl); - io_gl->gl_object = i_gl; - spin_unlock(&io_gl->gl_spin); - } - - gfs2_glock_hold(i_gl); - i_gl->gl_object = ip; - atomic_inc(&sdp->sd_inode_count); - *ipp = ip; - return 0; - -fail: - gfs2_meta_cache_flush(ip); - kmem_cache_free(gfs2_inode_cachep, ip); - *ipp = NULL; - return error; -} - -/** - * gfs2_inode_get - Create or get a reference on an inode - * @i_gl: The glock covering the inode - * @inum: The inode number - * @create: - * @ipp: pointer to put the returned inode in - * - * Returns: errno - */ - -int gfs2_inode_get(struct gfs2_glock *i_gl, const struct gfs2_inum *inum, - int create, struct gfs2_inode **ipp) -{ - struct gfs2_sbd *sdp = i_gl->gl_sbd; - struct gfs2_glock *io_gl; - int error = 0; - - gfs2_glmutex_lock(i_gl); - - *ipp = i_gl->gl_object; - if (*ipp) { - error = -ESTALE; - if ((*ipp)->i_num.no_formal_ino != inum->no_formal_ino) - goto out; - atomic_inc(&(*ipp)->i_count); - error = 0; - goto out; - } - - if (!create) - goto out; - - error = gfs2_glock_get(sdp, inum->no_addr, &gfs2_iopen_glops, - CREATE, &io_gl); - if (!error) { - error = inode_create(i_gl, inum, io_gl, LM_ST_SHARED, ipp, 1); - gfs2_glock_put(io_gl); - } - - out: - gfs2_glmutex_unlock(i_gl); - - return error; -} - -void gfs2_inode_hold(struct gfs2_inode *ip) -{ - gfs2_assert(ip->i_sbd, atomic_read(&ip->i_count) > 0); - atomic_inc(&ip->i_count); -} - -void gfs2_inode_put(struct gfs2_inode *ip) -{ - gfs2_assert(ip->i_sbd, atomic_read(&ip->i_count) > 0); - atomic_dec(&ip->i_count); -} - -void gfs2_inode_destroy(struct gfs2_inode *ip, int unlock) -{ - struct gfs2_sbd *sdp = ip->i_sbd; - struct gfs2_glock *i_gl = ip->i_gl; - - gfs2_assert_warn(sdp, !atomic_read(&ip->i_count)); - if (unlock) { - struct gfs2_glock *io_gl = ip->i_iopen_gh.gh_gl; - gfs2_assert(sdp, io_gl->gl_object == i_gl); - - spin_lock(&io_gl->gl_spin); - io_gl->gl_object = NULL; - spin_unlock(&io_gl->gl_spin); - gfs2_glock_put(i_gl); - - gfs2_glock_dq_uninit(&ip->i_iopen_gh); - } - - gfs2_meta_cache_flush(ip); - kmem_cache_free(gfs2_inode_cachep, ip); - - i_gl->gl_object = NULL; - gfs2_glock_put(i_gl); - - atomic_dec(&sdp->sd_inode_count); -} - -static int dinode_dealloc(struct gfs2_inode *ip, struct gfs2_unlinked *ul) -{ - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al; struct gfs2_rgrpd *rgd; int error; @@ -450,7 +288,7 @@ static int dinode_dealloc(struct gfs2_inode *ip, struct gfs2_unlinked *ul) if (error) goto out_rindex_relse; - error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_UNLINKED + + error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA, 1); if (error) goto out_rg_gunlock; @@ -459,191 +297,20 @@ static int dinode_dealloc(struct gfs2_inode *ip, struct gfs2_unlinked *ul) gfs2_free_di(rgd, ip); - error = gfs2_unlinked_ondisk_rm(sdp, ul); - gfs2_trans_end(sdp); clear_bit(GLF_STICKY, &ip->i_gl->gl_flags); - out_rg_gunlock: +out_rg_gunlock: gfs2_glock_dq_uninit(&al->al_rgd_gh); - - out_rindex_relse: +out_rindex_relse: gfs2_glock_dq_uninit(&al->al_ri_gh); - - out_qs: +out_qs: gfs2_quota_unhold(ip); - - out: - gfs2_alloc_put(ip); - - return error; -} - -/** - * inode_dealloc - Deallocate all on-disk blocks for an inode (dinode) - * @sdp: the filesystem - * @inum: the inode number to deallocate - * @io_gh: a holder for the iopen glock for this inode - * - * N.B. When we enter this we already hold the iopen glock and getting - * the glock for the inode means that we are grabbing the locks in the - * "wrong" order so we must only so a try lock operation and fail if we - * don't get the lock. Thats ok, since if we fail it means someone else - * is using the inode still and thus we shouldn't be deallocating it - * anyway. - * - * Returns: errno - */ - -static int inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul, - struct gfs2_holder *io_gh) -{ - struct gfs2_inode *ip; - struct gfs2_holder i_gh; - int error; - - error = gfs2_glock_nq_num(sdp, ul->ul_ut.ut_inum.no_addr, - &gfs2_inode_glops, LM_ST_EXCLUSIVE, - LM_FLAG_TRY_1CB|GL_DUMP, &i_gh); - switch(error) { - case 0: - break; - case GLR_TRYFAILED: - return 1; /* or back off and relock in different order? */ - default: - return error; - } - - gfs2_assert_warn(sdp, !i_gh.gh_gl->gl_object); - error = inode_create(i_gh.gh_gl, &ul->ul_ut.ut_inum, io_gh->gh_gl, - LM_ST_EXCLUSIVE, &ip, 0); - - if (error) - goto out; - - error = gfs2_inode_refresh(ip); - if (error) - goto out_iput; - - if (ip->i_di.di_nlink) { - if (gfs2_consist_inode(ip)) - gfs2_dinode_print(&ip->i_di); - error = -EIO; - goto out_iput; - } - - if (S_ISDIR(ip->i_di.di_mode) && - (ip->i_di.di_flags & GFS2_DIF_EXHASH)) { - error = gfs2_dir_exhash_dealloc(ip); - if (error) - goto out_iput; - } - - if (ip->i_di.di_eattr) { - error = gfs2_ea_dealloc(ip); - if (error) - goto out_iput; - } - - if (!gfs2_is_stuffed(ip)) { - error = gfs2_file_dealloc(ip); - if (error) - goto out_iput; - } - - error = dinode_dealloc(ip, ul); - if (error) - goto out_iput; - -out_iput: - gfs2_glmutex_lock(i_gh.gh_gl); - gfs2_inode_put(ip); - gfs2_inode_destroy(ip, 0); - gfs2_glmutex_unlock(i_gh.gh_gl); - out: - gfs2_glock_dq_uninit(&i_gh); - - return error; -} - -/** - * try_inode_dealloc - Try to deallocate an inode and all its blocks - * @sdp: the filesystem - * - * Returns: 0 on success, -errno on error, 1 on busy (inode open) - */ - -static int try_inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul) -{ - int error = 0; - struct gfs2_holder iogh; - - gfs2_try_toss_inode(sdp, &ul->ul_ut.ut_inum); - error = gfs2_glock_nq_num(sdp, ul->ul_ut.ut_inum.no_addr, - &gfs2_iopen_glops, LM_ST_EXCLUSIVE, - LM_FLAG_TRY_1CB, &iogh); - switch (error) { - case 0: - break; - case GLR_TRYFAILED: - return 1; - default: - return error; - } - - error = inode_dealloc(sdp, ul, &iogh); - gfs2_glock_dq_uninit(&iogh); - - return error; -} - -static int inode_dealloc_uninit(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul) -{ - struct gfs2_rgrpd *rgd; - struct gfs2_holder ri_gh, rgd_gh; - int error; - - error = gfs2_rindex_hold(sdp, &ri_gh); - if (error) - return error; - - rgd = gfs2_blk2rgrpd(sdp, ul->ul_ut.ut_inum.no_addr); - if (!rgd) { - gfs2_consist(sdp); - error = -EIO; - goto out; - } - - error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, &rgd_gh); - if (error) - goto out; - - error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_UNLINKED + RES_STATFS, 0); - if (error) - goto out_gunlock; - - gfs2_free_uninit_di(rgd, ul->ul_ut.ut_inum.no_addr); - gfs2_unlinked_ondisk_rm(sdp, ul); - - gfs2_trans_end(sdp); - - out_gunlock: - gfs2_glock_dq_uninit(&rgd_gh); - out: - gfs2_glock_dq_uninit(&ri_gh); - + gfs2_alloc_put(ip); return error; } -int gfs2_inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul) -{ - if (ul->ul_ut.ut_flags & GFS2_UTF_UNINIT) - return inode_dealloc_uninit(sdp, ul); - else - return try_inode_dealloc(sdp, ul); -} - /** * gfs2_change_nlink - Change nlink count on inode * @ip: The GFS2 inode @@ -654,6 +321,7 @@ int gfs2_inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul) int gfs2_change_nlink(struct gfs2_inode *ip, int diff) { + struct gfs2_sbd *sdp = ip->i_inode.i_sb->s_fs_info; struct buffer_head *dibh; uint32_t nlink; int error; @@ -678,8 +346,30 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff) gfs2_trans_add_bh(ip->i_gl, dibh, 1); gfs2_dinode_out(&ip->i_di, dibh->b_data); brelse(dibh); + mark_inode_dirty(&ip->i_inode); - return 0; + if (ip->i_di.di_nlink == 0) { + struct gfs2_rgrpd *rgd; + struct gfs2_holder ri_gh, rg_gh; + + error = gfs2_rindex_hold(sdp, &ri_gh); + if (error) + goto out; + error = -EIO; + rgd = gfs2_blk2rgrpd(sdp, ip->i_num.no_addr); + if (!rgd) + goto out_norgrp; + error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, &rg_gh); + if (error) + goto out_norgrp; + + gfs2_unlink_di(&ip->i_inode); /* mark inode unlinked */ + gfs2_glock_dq_uninit(&rg_gh); +out_norgrp: + gfs2_glock_dq_uninit(&ri_gh); + } +out: + return error; } struct inode *gfs2_lookup_simple(struct inode *dip, const char *name) @@ -703,18 +393,15 @@ struct inode *gfs2_lookup_simple(struct inode *dip, const char *name) * Returns: errno */ -struct inode *gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root, - struct nameidata *nd) +struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, + int is_root, struct nameidata *nd) { struct super_block *sb = dir->i_sb; - struct gfs2_inode *ipp; - struct gfs2_inode *dip = dir->u.generic_ip; - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_inode *dip = GFS2_I(dir); struct gfs2_holder d_gh; struct gfs2_inum inum; unsigned int type; - struct gfs2_glock *gl; int error = 0; struct inode *inode = NULL; @@ -742,34 +429,18 @@ struct inode *gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root, if (error) goto out; - error = gfs2_glock_get(sdp, inum.no_addr, &gfs2_inode_glops, - CREATE, &gl); - if (error) - goto out; - - error = gfs2_inode_get(gl, &inum, CREATE, &ipp); - if (!error) - gfs2_inode_min_init(ipp, type); - - gfs2_glock_put(gl); + inode = gfs2_inode_lookup(sb, &inum, type); out: gfs2_glock_dq_uninit(&d_gh); if (error == -ENOENT) return NULL; - if (error == 0) { - inode = gfs2_ip2v(ipp); - gfs2_inode_put(ipp); - if (!inode) - return ERR_PTR(-ENOMEM); - return inode; - } - return ERR_PTR(error); + return inode; } static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino) { - struct gfs2_inode *ip = sdp->sd_ir_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode); struct buffer_head *bh; struct gfs2_inum_range ir; int error; @@ -810,8 +481,8 @@ static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino) static int pick_formal_ino_2(struct gfs2_sbd *sdp, uint64_t *formal_ino) { - struct gfs2_inode *ip = sdp->sd_ir_inode->u.generic_ip; - struct gfs2_inode *m_ip = sdp->sd_inum_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode); + struct gfs2_inode *m_ip = GFS2_I(sdp->sd_inum_inode); struct gfs2_holder gh; struct buffer_head *bh; struct gfs2_inum_range ir; @@ -895,12 +566,12 @@ static int pick_formal_ino(struct gfs2_sbd *sdp, uint64_t *inum) * Returns: errno */ -static int create_ok(struct gfs2_inode *dip, struct qstr *name, +static int create_ok(struct gfs2_inode *dip, const struct qstr *name, unsigned int mode) { int error; - error = gfs2_repermission(dip->i_vnode, MAY_WRITE | MAY_EXEC, NULL); + error = gfs2_repermission(&dip->i_inode, MAY_WRITE | MAY_EXEC, NULL); if (error) return error; @@ -908,7 +579,7 @@ static int create_ok(struct gfs2_inode *dip, struct qstr *name, if (!dip->i_di.di_nlink) return -EPERM; - error = gfs2_dir_search(dip->i_vnode, name, NULL, NULL); + error = gfs2_dir_search(&dip->i_inode, name, NULL, NULL); switch (error) { case -ENOENT: error = 0; @@ -930,7 +601,7 @@ static int create_ok(struct gfs2_inode *dip, struct qstr *name, static void munge_mode_uid_gid(struct gfs2_inode *dip, unsigned int *mode, unsigned int *uid, unsigned int *gid) { - if (dip->i_sbd->sd_args.ar_suiddir && + if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir && (dip->i_di.di_mode & S_ISUID) && dip->i_di.di_uid) { if (S_ISDIR(*mode)) @@ -949,9 +620,9 @@ static void munge_mode_uid_gid(struct gfs2_inode *dip, unsigned int *mode, *gid = current->fsgid; } -static int alloc_dinode(struct gfs2_inode *dip, struct gfs2_unlinked *ul) +static int alloc_dinode(struct gfs2_inode *dip, struct gfs2_inum *inum) { - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); int error; gfs2_alloc_get(dip); @@ -961,15 +632,11 @@ static int alloc_dinode(struct gfs2_inode *dip, struct gfs2_unlinked *ul) if (error) goto out; - error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_UNLINKED + - RES_STATFS, 0); + error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS, 0); if (error) goto out_ipreserv; - ul->ul_ut.ut_inum.no_addr = gfs2_alloc_di(dip); - - ul->ul_ut.ut_flags = GFS2_UTF_UNINIT; - error = gfs2_unlinked_ondisk_add(sdp, ul); + inum->no_addr = gfs2_alloc_di(dip); gfs2_trans_end(sdp); @@ -997,7 +664,7 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, struct gfs2_inum *inum, unsigned int mode, unsigned int uid, unsigned int gid) { - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); struct gfs2_dinode *di; struct buffer_head *dibh; @@ -1049,9 +716,9 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, } static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, - unsigned int mode, struct gfs2_unlinked *ul) + unsigned int mode, struct gfs2_inum *inum) { - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); unsigned int uid, gid; int error; @@ -1066,28 +733,25 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, if (error) goto out_quota; - error = gfs2_trans_begin(sdp, RES_DINODE + RES_UNLINKED + RES_QUOTA, 0); + error = gfs2_trans_begin(sdp, RES_DINODE + RES_QUOTA, 0); if (error) goto out_quota; - ul->ul_ut.ut_flags = 0; - error = gfs2_unlinked_ondisk_munge(sdp, ul); - init_dinode(dip, gl, &ul->ul_ut.ut_inum, mode, uid, gid); + init_dinode(dip, gl, inum, mode, uid, gid); gfs2_quota_change(dip, +1, uid, gid); gfs2_trans_end(sdp); - out_quota: +out_quota: gfs2_quota_unlock(dip); - - out: +out: gfs2_alloc_put(dip); return error; } -static int link_dinode(struct gfs2_inode *dip, struct qstr *name, - struct gfs2_inode *ip, struct gfs2_unlinked *ul) +static int link_dinode(struct gfs2_inode *dip, const struct qstr *name, + struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); struct gfs2_alloc *al; int alloc_required; struct buffer_head *dibh; @@ -1099,7 +763,7 @@ static int link_dinode(struct gfs2_inode *dip, struct qstr *name, if (error) goto fail; - error = alloc_required = gfs2_diradd_alloc_required(dip->i_vnode, name); + error = alloc_required = gfs2_diradd_alloc_required(&dip->i_inode, name); if (alloc_required < 0) goto fail; if (alloc_required) { @@ -1116,20 +780,17 @@ static int link_dinode(struct gfs2_inode *dip, struct qstr *name, error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + al->al_rgd->rd_ri.ri_length + - 2 * RES_DINODE + RES_UNLINKED + + 2 * RES_DINODE + RES_STATFS + RES_QUOTA, 0); if (error) goto fail_ipreserv; } else { - error = gfs2_trans_begin(sdp, - RES_LEAF + - 2 * RES_DINODE + - RES_UNLINKED, 0); + error = gfs2_trans_begin(sdp, RES_LEAF + 2 * RES_DINODE, 0); if (error) goto fail_quota_locks; } - error = gfs2_dir_add(dip->i_vnode, name, &ip->i_num, IF2DT(ip->i_di.di_mode)); + error = gfs2_dir_add(&dip->i_inode, name, &ip->i_num, IF2DT(ip->i_di.di_mode)); if (error) goto fail_end_trans; @@ -1140,11 +801,6 @@ static int link_dinode(struct gfs2_inode *dip, struct qstr *name, gfs2_trans_add_bh(ip->i_gl, dibh, 1); gfs2_dinode_out(&ip->i_di, dibh->b_data); brelse(dibh); - - error = gfs2_unlinked_ondisk_rm(sdp, ul); - if (error) - goto fail_end_trans; - return 0; fail_end_trans: @@ -1178,23 +834,19 @@ fail: * Returns: An inode */ -struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, +struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, unsigned int mode) { struct inode *inode; struct gfs2_inode *dip = ghs->gh_gl->gl_object; - struct gfs2_sbd *sdp = dip->i_sbd; - struct gfs2_unlinked *ul; - struct gfs2_inode *ip; + struct inode *dir = &dip->i_inode; + struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); + struct gfs2_inum inum; int error; if (!name->len || name->len > GFS2_FNAMESIZE) return ERR_PTR(-ENAMETOOLONG); - error = gfs2_unlinked_get(sdp, &ul); - if (error) - return ERR_PTR(error); - gfs2_holder_reinit(LM_ST_EXCLUSIVE, 0, ghs); error = gfs2_glock_nq(ghs); if (error) @@ -1204,22 +856,21 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, if (error) goto fail_gunlock; - error = pick_formal_ino(sdp, &ul->ul_ut.ut_inum.no_formal_ino); + error = pick_formal_ino(sdp, &inum.no_formal_ino); if (error) goto fail_gunlock; - error = alloc_dinode(dip, ul); + error = alloc_dinode(dip, &inum); if (error) goto fail_gunlock; - if (ul->ul_ut.ut_inum.no_addr < dip->i_num.no_addr) { + if (inum.no_addr < dip->i_num.no_addr) { gfs2_glock_dq(ghs); - error = gfs2_glock_nq_num(sdp, ul->ul_ut.ut_inum.no_addr, + error = gfs2_glock_nq_num(sdp, inum.no_addr, &gfs2_inode_glops, LM_ST_EXCLUSIVE, GL_SKIP, ghs + 1); if (error) { - gfs2_unlinked_put(sdp, ul); return ERR_PTR(error); } @@ -1227,7 +878,6 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, error = gfs2_glock_nq(ghs); if (error) { gfs2_glock_dq_uninit(ghs + 1); - gfs2_unlinked_put(sdp, ul); return ERR_PTR(error); } @@ -1235,94 +885,47 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, if (error) goto fail_gunlock2; } else { - error = gfs2_glock_nq_num(sdp, ul->ul_ut.ut_inum.no_addr, + error = gfs2_glock_nq_num(sdp, inum.no_addr, &gfs2_inode_glops, LM_ST_EXCLUSIVE, GL_SKIP, ghs + 1); if (error) goto fail_gunlock; } - error = make_dinode(dip, ghs[1].gh_gl, mode, ul); + error = make_dinode(dip, ghs[1].gh_gl, mode, &inum); if (error) goto fail_gunlock2; - error = gfs2_inode_get(ghs[1].gh_gl, &ul->ul_ut.ut_inum, CREATE, &ip); - if (error) + inode = gfs2_inode_lookup(dir->i_sb, &inum, IF2DT(mode)); + if (IS_ERR(inode)) goto fail_gunlock2; - error = gfs2_inode_refresh(ip); + error = gfs2_inode_refresh(GFS2_I(inode)); if (error) goto fail_iput; - error = gfs2_acl_create(dip, ip); + error = gfs2_acl_create(dip, GFS2_I(inode)); if (error) goto fail_iput; - error = link_dinode(dip, name, ip, ul); + error = link_dinode(dip, name, GFS2_I(inode)); if (error) goto fail_iput; - gfs2_unlinked_put(sdp, ul); - - inode = gfs2_ip2v(ip); - gfs2_inode_put(ip); if (!inode) return ERR_PTR(-ENOMEM); return inode; fail_iput: - gfs2_inode_put(ip); - + iput(inode); fail_gunlock2: gfs2_glock_dq_uninit(ghs + 1); - fail_gunlock: gfs2_glock_dq(ghs); - fail: - gfs2_unlinked_put(sdp, ul); return ERR_PTR(error); } -/** - * gfs2_unlinki - Unlink a file - * @dip: The inode of the directory - * @name: The name of the file to be unlinked - * @ip: The inode of the file to be removed - * - * Assumes Glocks on both dip and ip are held. - * - * Returns: errno - */ - -int gfs2_unlinki(struct gfs2_inode *dip, struct qstr *name, - struct gfs2_inode *ip, struct gfs2_unlinked *ul) -{ - struct gfs2_sbd *sdp = dip->i_sbd; - int error; - - error = gfs2_dir_del(dip, name); - if (error) - return error; - - error = gfs2_change_nlink(ip, -1); - if (error) - return error; - - /* If this inode is being unlinked from the directory structure, - we need to mark that in the log so that it isn't lost during - a crash. */ - - if (!ip->i_di.di_nlink) { - ul->ul_ut.ut_inum = ip->i_num; - error = gfs2_unlinked_ondisk_add(sdp, ul); - if (!error) - set_bit(GLF_STICKY, &ip->i_gl->gl_flags); - } - - return error; -} - /** * gfs2_rmdiri - Remove a directory * @dip: The parent directory of the directory to be removed @@ -1334,10 +937,9 @@ int gfs2_unlinki(struct gfs2_inode *dip, struct qstr *name, * Returns: errno */ -int gfs2_rmdiri(struct gfs2_inode *dip, struct qstr *name, - struct gfs2_inode *ip, struct gfs2_unlinked *ul) +int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name, + struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = dip->i_sbd; struct qstr dotname; int error; @@ -1360,9 +962,7 @@ int gfs2_rmdiri(struct gfs2_inode *dip, struct qstr *name, if (error) return error; - dotname.len = 2; - dotname.name = ".."; - dotname.hash = gfs2_disk_hash(dotname.name, dotname.len); + gfs2_str2qstr(&dotname, ".."); error = gfs2_dir_del(ip, &dotname); if (error) return error; @@ -1371,15 +971,6 @@ int gfs2_rmdiri(struct gfs2_inode *dip, struct qstr *name, if (error) return error; - /* This inode is being unlinked from the directory structure and - we need to mark that in the log so that it isn't lost during - a crash. */ - - ul->ul_ut.ut_inum = ip->i_num; - error = gfs2_unlinked_ondisk_add(sdp, ul); - if (!error) - set_bit(GLF_STICKY, &ip->i_gl->gl_flags); - return error; } @@ -1394,30 +985,29 @@ int gfs2_rmdiri(struct gfs2_inode *dip, struct qstr *name, * Returns: 0 if the parent/child relationship is correct, errno if it isn't */ -int gfs2_unlink_ok(struct gfs2_inode *dip, struct qstr *name, +int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name, struct gfs2_inode *ip) { struct gfs2_inum inum; unsigned int type; int error; - if (IS_IMMUTABLE(ip->i_vnode) || IS_APPEND(ip->i_vnode)) + if (IS_IMMUTABLE(&ip->i_inode) || IS_APPEND(&ip->i_inode)) return -EPERM; if ((dip->i_di.di_mode & S_ISVTX) && dip->i_di.di_uid != current->fsuid && - ip->i_di.di_uid != current->fsuid && - !capable(CAP_FOWNER)) + ip->i_di.di_uid != current->fsuid && !capable(CAP_FOWNER)) return -EPERM; - if (IS_APPEND(dip->i_vnode)) + if (IS_APPEND(&dip->i_inode)) return -EPERM; - error = gfs2_repermission(dip->i_vnode, MAY_WRITE | MAY_EXEC, NULL); + error = gfs2_repermission(&dip->i_inode, MAY_WRITE | MAY_EXEC, NULL); if (error) return error; - error = gfs2_dir_search(dip->i_vnode, name, &inum, &type); + error = gfs2_dir_search(&dip->i_inode, name, &inum, &type); if (error) return error; @@ -1445,7 +1035,7 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, struct qstr *name, int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to) { - struct inode *dir = to->i_vnode; + struct inode *dir = &to->i_inode; struct super_block *sb = dir->i_sb; struct inode *tmp; struct qstr dotdot; @@ -1456,7 +1046,7 @@ int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to) igrab(dir); for (;;) { - if (dir == this->i_vnode) { + if (dir == &this->i_inode) { error = -EINVAL; break; } @@ -1528,12 +1118,10 @@ int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len) memcpy(*buf, dibh->b_data + sizeof(struct gfs2_dinode), x); *len = x; - out_brelse: +out_brelse: brelse(dibh); - - out: +out: gfs2_glock_dq_uninit(&i_gh); - return error; } @@ -1622,12 +1210,10 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh) return 0; - fail_end_trans: +fail_end_trans: gfs2_trans_end(sdp); - - fail: +fail: gfs2_glock_dq(gh); - return error; } @@ -1722,49 +1308,6 @@ int gfs2_glock_nq_m_atime(unsigned int num_gh, struct gfs2_holder *ghs) return error; } -/** - * gfs2_try_toss_vnode - See if we can toss a vnode from memory - * @ip: the inode - * - * Returns: 1 if the vnode was tossed - */ - -void gfs2_try_toss_vnode(struct gfs2_inode *ip) -{ - struct inode *inode; - - inode = gfs2_ip2v_lookup(ip); - if (!inode) - return; - - d_prune_aliases(inode); - - if (S_ISDIR(ip->i_di.di_mode)) { - struct list_head *head = &inode->i_dentry; - struct dentry *d = NULL; - - spin_lock(&dcache_lock); - if (list_empty(head)) - spin_unlock(&dcache_lock); - else { - d = list_entry(head->next, struct dentry, d_alias); - dget_locked(d); - spin_unlock(&dcache_lock); - - if (have_submounts(d)) - dput(d); - else { - shrink_dcache_parent(d); - dput(d); - d_prune_aliases(inode); - } - } - } - - inode->i_nlink = 0; - iput(inode); -} - static int __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr) @@ -1774,8 +1317,8 @@ __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr) error = gfs2_meta_inode_buffer(ip, &dibh); if (!error) { - error = inode_setattr(ip->i_vnode, attr); - gfs2_assert_warn(ip->i_sbd, !error); + error = inode_setattr(&ip->i_inode, attr); + gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error); gfs2_inode_attr_out(ip); gfs2_trans_add_bh(ip->i_gl, dibh, 1); @@ -1802,13 +1345,13 @@ int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr) if (current->journal_info) return __gfs2_setattr_simple(ip, attr); - error = gfs2_trans_begin(ip->i_sbd, RES_DINODE, 0); + error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE, 0); if (error) return error; error = __gfs2_setattr_simple(ip, attr); - gfs2_trans_end(ip->i_sbd); + gfs2_trans_end(GFS2_SB(&ip->i_inode)); return error; } diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h index 5ef21317b2f6d0..30cfcc10beb298 100644 --- a/fs/gfs2/inode.h +++ b/fs/gfs2/inode.h @@ -27,32 +27,20 @@ static inline int gfs2_is_dir(struct gfs2_inode *ip) void gfs2_inode_attr_in(struct gfs2_inode *ip); void gfs2_inode_attr_out(struct gfs2_inode *ip); -struct inode *gfs2_ip2v_lookup(struct gfs2_inode *ip); -struct inode *gfs2_ip2v(struct gfs2_inode *ip); -struct inode *gfs2_iget(struct super_block *sb, struct gfs2_inum *inum); +struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum *inum, unsigned type); +struct inode *gfs2_ilookup(struct super_block *sb, struct gfs2_inum *inum); -void gfs2_inode_min_init(struct gfs2_inode *ip, unsigned int type); int gfs2_inode_refresh(struct gfs2_inode *ip); -int gfs2_inode_get(struct gfs2_glock *i_gl, - const struct gfs2_inum *inum, int create, - struct gfs2_inode **ipp); -void gfs2_inode_hold(struct gfs2_inode *ip); -void gfs2_inode_put(struct gfs2_inode *ip); -void gfs2_inode_destroy(struct gfs2_inode *ip, int unlock); - -int gfs2_inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul); - +int gfs2_dinode_dealloc(struct gfs2_inode *inode); int gfs2_change_nlink(struct gfs2_inode *ip, int diff); -struct inode *gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root, - struct nameidata *nd); -struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, +struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, + int is_root, struct nameidata *nd); +struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, unsigned int mode); -int gfs2_unlinki(struct gfs2_inode *dip, struct qstr *name, - struct gfs2_inode *ip, struct gfs2_unlinked *ul); -int gfs2_rmdiri(struct gfs2_inode *dip, struct qstr *name, - struct gfs2_inode *ip, struct gfs2_unlinked *ul); -int gfs2_unlink_ok(struct gfs2_inode *dip, struct qstr *name, +int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name, + struct gfs2_inode *ip); +int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name, struct gfs2_inode *ip); int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to); int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len); @@ -60,8 +48,6 @@ int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len); int gfs2_glock_nq_atime(struct gfs2_holder *gh); int gfs2_glock_nq_m_atime(unsigned int num_gh, struct gfs2_holder *ghs); -void gfs2_try_toss_vnode(struct gfs2_inode *ip); - int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr); int gfs2_repermission(struct inode *inode, int mask, struct nameidata *nd); diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 2a8b4b71dd1fa1..483d4fa987f64d 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -213,6 +213,9 @@ static uint64_t log_bmap(struct gfs2_sbd *sdp, unsigned int lbn) int bdy; error = gfs2_block_map(sdp->sd_jdesc->jd_inode, lbn, &new, &dbn, &bdy); + if (!(!error && dbn)) { + printk(KERN_INFO "error=%d, dbn=%llu lbn=%u", error, dbn, lbn); + } gfs2_assert_withdraw(sdp, !error && dbn); return dbn; diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index e4c75a74df5bc5..a76f1a77892008 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -184,8 +184,7 @@ static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) static void buf_lo_before_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); if (pass != 0) return; @@ -198,8 +197,8 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, struct gfs2_log_descriptor *ld, __be64 *ptr, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(jd->jd_inode); + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); struct gfs2_glock *gl = ip->i_gl; unsigned int blks = be32_to_cpu(ld->ld_data1); struct buffer_head *bh_log, *bh_ip; @@ -245,8 +244,8 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(jd->jd_inode); + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); if (error) { gfs2_meta_sync(ip->i_gl, @@ -332,8 +331,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) static void revoke_lo_before_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); if (pass != 0) return; @@ -346,8 +344,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, struct gfs2_log_descriptor *ld, __be64 *ptr, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); unsigned int blks = be32_to_cpu(ld->ld_length); unsigned int revokes = be32_to_cpu(ld->ld_data1); struct buffer_head *bh; @@ -393,8 +390,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); if (error) { gfs2_revoke_clean(sdp); @@ -465,7 +461,7 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le); struct gfs2_trans *tr = current->journal_info; struct address_space *mapping = bd->bd_bh->b_page->mapping; - struct gfs2_inode *ip = mapping->host->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(mapping->host); tr->tr_touched = 1; if (!list_empty(&bd->bd_list_tr) && @@ -665,8 +661,8 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, struct gfs2_log_descriptor *ld, __be64 *ptr, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(jd->jd_inode); + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); struct gfs2_glock *gl = ip->i_gl; unsigned int blks = be32_to_cpu(ld->ld_data1); struct buffer_head *bh_log, *bh_ip; @@ -716,8 +712,8 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(jd->jd_inode); + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); if (error) { gfs2_meta_sync(ip->i_gl, diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index b24d0b40d965c6..c112943ee8c193 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c @@ -29,8 +29,6 @@ static void gfs2_init_inode_once(void *foo, kmem_cache_t *cachep, unsigned long if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == SLAB_CTOR_CONSTRUCTOR) { inode_init_once(&ip->i_inode); - atomic_set(&ip->i_count, 0); - ip->i_vnode = &ip->i_inode; spin_lock_init(&ip->i_spin); init_rwsem(&ip->i_rw_mutex); memset(ip->i_cache, 0, sizeof(ip->i_cache)); diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index c78517225f61a7..2523d42a02de7d 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -91,9 +91,6 @@ static void stuck_releasepage(struct buffer_head *bh) fs_warn(sdp, "ip = %llu %llu\n", (unsigned long long)ip->i_num.no_formal_ino, (unsigned long long)ip->i_num.no_addr); - fs_warn(sdp, "ip->i_count = %d, ip->i_vnode = %s\n", - atomic_read(&ip->i_count), - (ip->i_vnode) ? "!NULL" : "NULL"); for (x = 0; x < GFS2_MAX_META_HEIGHT; x++) fs_warn(sdp, "ip->i_cache[%u] = %s\n", @@ -567,7 +564,6 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh, bd = kmem_cache_alloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL), memset(bd, 0, sizeof(struct gfs2_bufdata)); - bd->bd_bh = bh; bd->bd_gl = gl; @@ -664,7 +660,7 @@ void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh, void gfs2_meta_wipe(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct inode *aspace = ip->i_gl->gl_aspace; struct buffer_head *bh; @@ -770,7 +766,7 @@ int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, uint64_t num, if (new) meta_prep_new(bh); else { - error = gfs2_meta_reread(ip->i_sbd, bh, + error = gfs2_meta_reread(GFS2_SB(&ip->i_inode), bh, DIO_START | DIO_WAIT); if (error) { brelse(bh); @@ -797,7 +793,7 @@ int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, uint64_t num, } if (new) { - if (gfs2_assert_warn(ip->i_sbd, height)) { + if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), height)) { brelse(bh); return -EIO; } @@ -805,7 +801,7 @@ int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, uint64_t num, gfs2_metatype_set(bh, GFS2_METATYPE_IN, GFS2_FORMAT_IN); gfs2_buffer_clear_tail(bh, sizeof(struct gfs2_meta_header)); - } else if (gfs2_metatype_check(ip->i_sbd, bh, + } else if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), bh, (height) ? GFS2_METATYPE_IN : GFS2_METATYPE_DI)) { brelse(bh); return -EIO; diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c index be5c86e5787edc..09154ad7b2706b 100644 --- a/fs/gfs2/ondisk.c +++ b/fs/gfs2/ondisk.c @@ -293,23 +293,6 @@ void gfs2_statfs_change_out(struct gfs2_statfs_change *sc, char *buf) str->sc_dinodes = cpu_to_be64(sc->sc_dinodes); } -void gfs2_unlinked_tag_in(struct gfs2_unlinked_tag *ut, char *buf) -{ - struct gfs2_unlinked_tag *str = (struct gfs2_unlinked_tag *)buf; - - gfs2_inum_in(&ut->ut_inum, buf); - ut->ut_flags = be32_to_cpu(str->ut_flags); -} - -void gfs2_unlinked_tag_out(struct gfs2_unlinked_tag *ut, char *buf) -{ - struct gfs2_unlinked_tag *str = (struct gfs2_unlinked_tag *)buf; - - gfs2_inum_out(&ut->ut_inum, buf); - str->ut_flags = cpu_to_be32(ut->ut_flags); - str->__pad = 0; -} - void gfs2_quota_change_in(struct gfs2_quota_change *qc, char *buf) { struct gfs2_quota_change *str = (struct gfs2_quota_change *)buf; diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 16d3ebd320926c..207363aed11216 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -81,7 +81,6 @@ int gfs2_get_block(struct inode *inode, sector_t lblock, static int get_block_noalloc(struct inode *inode, sector_t lblock, struct buffer_head *bh_result, int create) { - struct gfs2_inode *ip = inode->u.generic_ip; int new = 0; uint64_t dblock; int error; @@ -93,7 +92,7 @@ static int get_block_noalloc(struct inode *inode, sector_t lblock, if (dblock) map_bh(bh_result, inode->i_sb, dblock); - else if (gfs2_assert_withdraw(ip->i_sbd, !create)) + else if (gfs2_assert_withdraw(GFS2_SB(inode), !create)) error = -EIO; if (boundary) set_buffer_boundary(bh_result); @@ -114,8 +113,8 @@ static int get_block_noalloc(struct inode *inode, sector_t lblock, static int gfs2_writepage(struct page *page, struct writeback_control *wbc) { struct inode *inode = page->mapping->host; - struct gfs2_inode *ip = page->mapping->host->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(page->mapping->host); + struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host); loff_t i_size = i_size_read(inode); pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT; unsigned offset; @@ -216,8 +215,8 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page) static int gfs2_readpage(struct file *file, struct page *page) { - struct gfs2_inode *ip = page->mapping->host->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(page->mapping->host); + struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host); struct gfs2_holder gh; int error; @@ -271,8 +270,8 @@ static int gfs2_readpages(struct file *file, struct address_space *mapping, struct list_head *pages, unsigned nr_pages) { struct inode *inode = mapping->host; - struct gfs2_inode *ip = inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); struct gfs2_holder gh; unsigned page_idx; int ret; @@ -345,8 +344,8 @@ out_unlock: static int gfs2_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to) { - struct gfs2_inode *ip = page->mapping->host->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(page->mapping->host); + struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host); unsigned int data_blocks, ind_blocks, rblocks; int alloc_required; int error = 0; @@ -440,8 +439,8 @@ static int gfs2_commit_write(struct file *file, struct page *page, unsigned from, unsigned to) { struct inode *inode = page->mapping->host; - struct gfs2_inode *ip = inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); int error = -EOPNOTSUPP; struct buffer_head *dibh; struct gfs2_alloc *al = &ip->i_alloc;; @@ -520,7 +519,7 @@ fail_nounlock: static sector_t gfs2_bmap(struct address_space *mapping, sector_t lblock) { - struct gfs2_inode *ip = mapping->host->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(mapping->host); struct gfs2_holder i_gh; sector_t dblock = 0; int error; @@ -594,7 +593,7 @@ static ssize_t gfs2_direct_IO_write(struct kiocb *iocb, const struct iovec *iov, { struct file *file = iocb->ki_filp; struct inode *inode = file->f_mapping->host; - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_holder gh; int rv; @@ -641,8 +640,8 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb, { struct file *file = iocb->ki_filp; struct inode *inode = file->f_mapping->host; - struct gfs2_inode *ip = inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); if (rw == WRITE) return gfs2_direct_IO_write(iocb, iov, offset, nr_segs); diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c index fef415e2068ee0..fd55979ec42810 100644 --- a/fs/gfs2/ops_dentry.c +++ b/fs/gfs2/ops_dentry.c @@ -38,8 +38,8 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd) { struct dentry *parent = dget_parent(dentry); - struct gfs2_sbd *sdp = parent->d_inode->i_sb->s_fs_info; - struct gfs2_inode *dip = parent->d_inode->u.generic_ip; + struct gfs2_sbd *sdp = GFS2_SB(parent->d_inode); + struct gfs2_inode *dip = GFS2_I(parent->d_inode); struct inode *inode = dentry->d_inode; struct gfs2_holder d_gh; struct gfs2_inode *ip; @@ -71,7 +71,7 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd) goto fail_gunlock; } - ip = inode->u.generic_ip; + ip = GFS2_I(inode); if (!gfs2_inum_equal(&ip->i_num, &inum)) goto invalid_gunlock; diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index a376ead7d0cdd1..eacc1c092f91f1 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c @@ -66,7 +66,7 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len, { struct inode *inode = dentry->d_inode; struct super_block *sb = inode->i_sb; - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); if (*len < 4 || (connectable && *len < 8)) return 255; @@ -86,8 +86,8 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len, spin_lock(&dentry->d_lock); inode = dentry->d_parent->d_inode; - ip = inode->u.generic_ip; - gfs2_inode_hold(ip); + ip = GFS2_I(inode); + igrab(inode); spin_unlock(&dentry->d_lock); fh[4] = ip->i_num.no_formal_ino >> 32; @@ -100,7 +100,7 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len, fh[7] = cpu_to_be32(fh[7]); *len = 8; - gfs2_inode_put(ip); + iput(inode); return *len; } @@ -142,8 +142,8 @@ static int gfs2_get_name(struct dentry *parent, char *name, if (!S_ISDIR(dir->i_mode) || !inode) return -EINVAL; - dip = dir->u.generic_ip; - ip = inode->u.generic_ip; + dip = GFS2_I(dir); + ip = GFS2_I(inode); *name = 0; gnfd.inum = ip->i_num; @@ -189,39 +189,30 @@ static struct dentry *gfs2_get_parent(struct dentry *child) static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_p) { struct gfs2_sbd *sdp = sb->s_fs_info; - struct gfs2_inum *inum = (struct gfs2_inum *)inum_p; + struct gfs2_inum *inum = inum_p; struct gfs2_holder i_gh, ri_gh, rgd_gh; struct gfs2_rgrpd *rgd; - struct gfs2_inode *ip; struct inode *inode; struct dentry *dentry; int error; /* System files? */ - inode = gfs2_iget(sb, inum); + inode = gfs2_ilookup(sb, inum); if (inode) { - ip = inode->u.generic_ip; - if (ip->i_num.no_formal_ino != inum->no_formal_ino) { + if (GFS2_I(inode)->i_num.no_formal_ino != inum->no_formal_ino) { iput(inode); return ERR_PTR(-ESTALE); } goto out_inode; } - error = gfs2_glock_nq_num(sdp, - inum->no_addr, &gfs2_inode_glops, + error = gfs2_glock_nq_num(sdp, inum->no_addr, &gfs2_inode_glops, LM_ST_SHARED, LM_FLAG_ANY | GL_LOCAL_EXCL, &i_gh); if (error) return ERR_PTR(error); - error = gfs2_inode_get(i_gh.gh_gl, inum, NO_CREATE, &ip); - if (error) - goto fail; - if (ip) - goto out_ip; - error = gfs2_rindex_hold(sdp, &ri_gh); if (error) goto fail; @@ -242,32 +233,29 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_p) gfs2_glock_dq_uninit(&rgd_gh); gfs2_glock_dq_uninit(&ri_gh); - error = gfs2_inode_get(i_gh.gh_gl, inum, CREATE, &ip); - if (error) + inode = gfs2_inode_lookup(sb, inum, DT_UNKNOWN); + if (!inode) + goto fail; + if (IS_ERR(inode)) { + error = PTR_ERR(inode); goto fail; + } - error = gfs2_inode_refresh(ip); + error = gfs2_inode_refresh(GFS2_I(inode)); if (error) { - gfs2_inode_put(ip); + iput(inode); goto fail; } - out_ip: error = -EIO; - if (ip->i_di.di_flags & GFS2_DIF_SYSTEM) { - gfs2_inode_put(ip); + if (GFS2_I(inode)->i_di.di_flags & GFS2_DIF_SYSTEM) { + iput(inode); goto fail; } gfs2_glock_dq_uninit(&i_gh); - inode = gfs2_ip2v(ip); - gfs2_inode_put(ip); - - if (!inode) - return ERR_PTR(-ENOMEM); - - out_inode: +out_inode: dentry = d_alloc_anon(inode); if (!dentry) { iput(inode); @@ -276,13 +264,13 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_p) return dentry; - fail_rgd: +fail_rgd: gfs2_glock_dq_uninit(&rgd_gh); - fail_rindex: +fail_rindex: gfs2_glock_dq_uninit(&ri_gh); - fail: +fail: gfs2_glock_dq_uninit(&i_gh); return ERR_PTR(error); } diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index 1e8f602c1e507e..222f3be3e06e82 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c @@ -105,7 +105,7 @@ static int gfs2_read_actor(read_descriptor_t *desc, struct page *page, int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state, char *buf, loff_t *pos, unsigned size) { - struct inode *inode = ip->i_vnode; + struct inode *inode = &ip->i_inode; read_descriptor_t desc; desc.written = 0; desc.arg.buf = buf; @@ -131,7 +131,7 @@ int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state, static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin) { - struct gfs2_inode *ip = file->f_mapping->host->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); struct gfs2_holder i_gh; loff_t error; @@ -178,7 +178,7 @@ static ssize_t __gfs2_file_aio_read(struct kiocb *iocb, unsigned long nr_segs, loff_t *ppos) { struct file *filp = iocb->ki_filp; - struct gfs2_inode *ip = filp->f_mapping->host->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(filp->f_mapping->host); struct gfs2_holder gh; ssize_t retval; unsigned long seg; @@ -361,13 +361,13 @@ static int filldir_reg_func(void *opaque, const char *name, unsigned int length, static int readdir_reg(struct file *file, void *dirent, filldir_t filldir) { struct inode *dir = file->f_mapping->host; - struct gfs2_inode *dip = dir->u.generic_ip; + struct gfs2_inode *dip = GFS2_I(dir); struct filldir_reg fdr; struct gfs2_holder d_gh; uint64_t offset = file->f_pos; int error; - fdr.fdr_sbd = dip->i_sbd; + fdr.fdr_sbd = GFS2_SB(dir); fdr.fdr_prefetch = 1; fdr.fdr_filldir = filldir; fdr.fdr_opaque = dirent; @@ -451,8 +451,8 @@ static int filldir_bad_func(void *opaque, const char *name, unsigned int length, static int readdir_bad(struct file *file, void *dirent, filldir_t filldir) { struct inode *dir = file->f_mapping->host; - struct gfs2_inode *dip = dir->u.generic_ip; - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_inode *dip = GFS2_I(dir); + struct gfs2_sbd *sdp = GFS2_SB(dir); struct filldir_reg fdr; unsigned int entries, size; struct filldir_bad *fdb; @@ -561,7 +561,7 @@ static const u32 gfs2_to_iflags[32] = { static int gfs2_get_flags(struct file *filp, u32 __user *ptr) { struct inode *inode = filp->f_dentry->d_inode; - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_holder gh; int error; u32 iflags; @@ -601,8 +601,8 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr) static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask) { struct inode *inode = filp->f_dentry->d_inode; - struct gfs2_inode *ip = inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); struct buffer_head *bh; struct gfs2_holder gh; int error; @@ -693,7 +693,7 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) static int gfs2_mmap(struct file *file, struct vm_area_struct *vma) { - struct gfs2_inode *ip = file->f_mapping->host->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); struct gfs2_holder i_gh; int error; @@ -728,7 +728,7 @@ static int gfs2_mmap(struct file *file, struct vm_area_struct *vma) static int gfs2_open(struct inode *inode, struct file *file) { - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_holder i_gh; struct gfs2_file *fp; int error; @@ -739,7 +739,7 @@ static int gfs2_open(struct inode *inode, struct file *file) mutex_init(&fp->f_fl_mutex); - gfs2_assert_warn(ip->i_sbd, !file->private_data); + gfs2_assert_warn(GFS2_SB(inode), !file->private_data); file->private_data = fp; if (S_ISREG(ip->i_di.di_mode)) { @@ -808,7 +808,7 @@ static int gfs2_close(struct inode *inode, struct file *file) static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync) { - struct gfs2_inode *ip = dentry->d_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(dentry->d_inode); gfs2_log_flush(ip->i_gl->gl_sbd, ip->i_gl); @@ -826,8 +826,8 @@ static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync) static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) { - struct gfs2_inode *ip = file->f_mapping->host->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); + struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); struct lm_lockname name = { .ln_number = ip->i_num.no_addr, .ln_type = LM_TYPE_PLOCK }; @@ -881,7 +881,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) { struct gfs2_file *fp = file->private_data; struct gfs2_holder *fl_gh = &fp->f_fl_gh; - struct gfs2_inode *ip = file->f_dentry->d_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(file->f_dentry->d_inode); struct gfs2_glock *gl; unsigned int state; int flags; @@ -901,7 +901,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) &(struct file_lock){.fl_type = F_UNLCK}); gfs2_glock_dq_uninit(fl_gh); } else { - error = gfs2_glock_get(ip->i_sbd, + error = gfs2_glock_get(GFS2_SB(&ip->i_inode), ip->i_num.no_addr, &gfs2_flock_glops, CREATE, &gl); if (error) @@ -918,7 +918,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) error = -EAGAIN; } else { error = flock_lock_file_wait(file, fl); - gfs2_assert_warn(ip->i_sbd, !error); + gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error); } out: @@ -950,8 +950,8 @@ static void do_unflock(struct file *file, struct file_lock *fl) static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl) { - struct gfs2_inode *ip = file->f_mapping->host->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); + struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); if (!(fl->fl_flags & FL_FLOCK)) return -ENOLCK; diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index a459820455091b..b68eb6b4a4c1ec 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -32,7 +32,6 @@ #include "recovery.h" #include "rgrp.h" #include "super.h" -#include "unlinked.h" #include "sys.h" #include "util.h" @@ -80,10 +79,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb) spin_lock_init(&sdp->sd_jindex_spin); mutex_init(&sdp->sd_jindex_mutex); - INIT_LIST_HEAD(&sdp->sd_unlinked_list); - spin_lock_init(&sdp->sd_unlinked_spin); - mutex_init(&sdp->sd_unlinked_mutex); - INIT_LIST_HEAD(&sdp->sd_quota_list); spin_lock_init(&sdp->sd_quota_spin); mutex_init(&sdp->sd_quota_mutex); @@ -248,19 +243,19 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh, return 0; - fail_trans: +fail_trans: gfs2_glock_put(sdp->sd_trans_gl); - fail_rename: +fail_rename: gfs2_glock_put(sdp->sd_rename_gl); - fail_live: +fail_live: gfs2_glock_dq_uninit(&sdp->sd_live_gh); - fail_mount: +fail_mount: gfs2_glock_dq_uninit(mount_gh); - fail: +fail: while (sdp->sd_glockd_num--) kthread_stop(sdp->sd_glockd_process[sdp->sd_glockd_num]); @@ -269,28 +264,10 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh, return error; } -static struct inode *gfs2_lookup_root(struct gfs2_sbd *sdp, - const struct gfs2_inum *inum) +static struct inode *gfs2_lookup_root(struct super_block *sb, + struct gfs2_inum *inum) { - int error; - struct gfs2_glock *gl; - struct gfs2_inode *ip; - struct inode *inode; - - error = gfs2_glock_get(sdp, inum->no_addr, &gfs2_inode_glops, - CREATE, &gl); - if (!error) { - error = gfs2_inode_get(gl, inum, CREATE, &ip); - if (!error) { - gfs2_inode_min_init(ip, DT_DIR); - inode = gfs2_ip2v(ip); - gfs2_inode_put(ip); - gfs2_glock_put(gl); - return inode; - } - gfs2_glock_put(gl); - } - return ERR_PTR(error); + return gfs2_inode_lookup(sb, inum, DT_DIR); } static int init_sb(struct gfs2_sbd *sdp, int silent, int undo) @@ -305,8 +282,7 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo) return 0; } - error = gfs2_glock_nq_num(sdp, - GFS2_SB_LOCK, &gfs2_meta_glops, + error = gfs2_glock_nq_num(sdp, GFS2_SB_LOCK, &gfs2_meta_glops, LM_ST_SHARED, 0, &sb_gh); if (error) { fs_err(sdp, "can't acquire superblock glock: %d\n", error); @@ -345,7 +321,7 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo) inum = &sdp->sd_sb.sb_root_dir; if (sb->s_type == &gfs2meta_fs_type) inum = &sdp->sd_sb.sb_master_dir; - inode = gfs2_lookup_root(sdp, inum); + inode = gfs2_lookup_root(sb, inum); if (IS_ERR(inode)) { error = PTR_ERR(inode); fs_err(sdp, "can't read in root inode: %d\n", error); @@ -382,7 +358,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) fs_err(sdp, "can't lookup journal index: %d\n", error); return PTR_ERR(sdp->sd_jindex); } - ip = sdp->sd_jindex->u.generic_ip; + ip = GFS2_I(sdp->sd_jindex); set_bit(GLF_STICKY, &ip->i_gl->gl_flags); /* Load in the journal index special file */ @@ -413,8 +389,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) } sdp->sd_jdesc = gfs2_jdesc_find(sdp, sdp->sd_lockstruct.ls_jid); - error = gfs2_glock_nq_num(sdp, - sdp->sd_lockstruct.ls_jid, + error = gfs2_glock_nq_num(sdp, sdp->sd_lockstruct.ls_jid, &gfs2_journal_glops, LM_ST_EXCLUSIVE, LM_FLAG_NOEXP, &sdp->sd_journal_gh); @@ -423,9 +398,8 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) goto fail_jindex; } - ip = sdp->sd_jdesc->jd_inode->u.generic_ip; - error = gfs2_glock_nq_init(ip->i_gl, - LM_ST_SHARED, + ip = GFS2_I(sdp->sd_jdesc->jd_inode); + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_NOEXP | GL_EXACT, &sdp->sd_jinode_gh); if (error) { @@ -509,7 +483,7 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo) if (undo) goto fail_qinode; - inode = gfs2_lookup_root(sdp, &sdp->sd_sb.sb_master_dir); + inode = gfs2_lookup_root(sdp->sd_vfs, &sdp->sd_sb.sb_master_dir); if (IS_ERR(inode)) { error = PTR_ERR(inode); fs_err(sdp, "can't read in master directory: %d\n", error); @@ -545,7 +519,7 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo) fs_err(sdp, "can't get resource index inode: %d\n", error); goto fail_statfs; } - ip = sdp->sd_rindex->u.generic_ip; + ip = GFS2_I(sdp->sd_rindex); set_bit(GLF_STICKY, &ip->i_gl->gl_flags); sdp->sd_rindex_vn = ip->i_gl->gl_vn - 1; @@ -614,14 +588,6 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) goto fail_ir_i; } - sprintf(buf, "unlinked_tag%u", sdp->sd_jdesc->jd_jid); - sdp->sd_ut_inode = gfs2_lookup_simple(pn, buf); - if (IS_ERR(sdp->sd_ut_inode)) { - error = PTR_ERR(sdp->sd_ut_inode); - fs_err(sdp, "can't find local \"ut\" file: %d\n", error); - goto fail_sc_i; - } - sprintf(buf, "quota_change%u", sdp->sd_jdesc->jd_jid); sdp->sd_qc_inode = gfs2_lookup_simple(pn, buf); if (IS_ERR(sdp->sd_qc_inode)) { @@ -633,7 +599,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) iput(pn); pn = NULL; - ip = sdp->sd_ir_inode->u.generic_ip; + ip = GFS2_I(sdp->sd_ir_inode); error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &sdp->sd_ir_gh); @@ -642,7 +608,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) goto fail_qc_i; } - ip = sdp->sd_sc_inode->u.generic_ip; + ip = GFS2_I(sdp->sd_sc_inode); error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &sdp->sd_sc_gh); @@ -651,16 +617,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) goto fail_ir_gh; } - ip = sdp->sd_ut_inode->u.generic_ip; - error = gfs2_glock_nq_init(ip->i_gl, - LM_ST_EXCLUSIVE, 0, - &sdp->sd_ut_gh); - if (error) { - fs_err(sdp, "can't lock local \"ut\" file: %d\n", error); - goto fail_sc_gh; - } - - ip = sdp->sd_qc_inode->u.generic_ip; + ip = GFS2_I(sdp->sd_qc_inode); error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &sdp->sd_qc_gh); @@ -675,9 +632,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) gfs2_glock_dq_uninit(&sdp->sd_qc_gh); fail_ut_gh: - gfs2_glock_dq_uninit(&sdp->sd_ut_gh); - fail_sc_gh: gfs2_glock_dq_uninit(&sdp->sd_sc_gh); fail_ir_gh: @@ -687,9 +642,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) iput(sdp->sd_qc_inode); fail_ut_i: - iput(sdp->sd_ut_inode); - fail_sc_i: iput(sdp->sd_sc_inode); fail_ir_i: @@ -707,7 +660,7 @@ static int init_threads(struct gfs2_sbd *sdp, int undo) int error = 0; if (undo) - goto fail_inoded; + goto fail_quotad; sdp->sd_log_flush_time = jiffies; sdp->sd_jindex_refresh_time = jiffies; @@ -731,25 +684,13 @@ static int init_threads(struct gfs2_sbd *sdp, int undo) } sdp->sd_quotad_process = p; - p = kthread_run(gfs2_inoded, sdp, "gfs2_inoded"); - error = IS_ERR(p); - if (error) { - fs_err(sdp, "can't start inoded thread: %d\n", error); - goto fail_quotad; - } - sdp->sd_inoded_process = p; - return 0; - fail_inoded: - kthread_stop(sdp->sd_inoded_process); - fail_quotad: +fail_quotad: kthread_stop(sdp->sd_quotad_process); - - fail: +fail: kthread_stop(sdp->sd_logd_process); - return error; } diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 0c06f92368f2d2..f678f6b62afd76 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -38,7 +38,6 @@ #include "quota.h" #include "rgrp.h" #include "trans.h" -#include "unlinked.h" #include "util.h" /** @@ -53,8 +52,8 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) { - struct gfs2_inode *dip = dir->u.generic_ip; - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_inode *dip = GFS2_I(dir); + struct gfs2_sbd *sdp = GFS2_SB(dir); struct gfs2_holder ghs[2]; struct inode *inode; int new = 1; @@ -141,10 +140,10 @@ static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry, static int gfs2_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) { - struct gfs2_inode *dip = dir->u.generic_ip; - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_inode *dip = GFS2_I(dir); + struct gfs2_sbd *sdp = GFS2_SB(dir); struct inode *inode = old_dentry->d_inode; - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_holder ghs[2]; int alloc_required; int error; @@ -231,30 +230,29 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, error = gfs2_change_nlink(ip, +1); - out_end_trans: +out_end_trans: gfs2_trans_end(sdp); - out_ipres: +out_ipres: if (alloc_required) gfs2_inplace_release(dip); - out_gunlock_q: +out_gunlock_q: if (alloc_required) gfs2_quota_unlock(dip); - out_alloc: +out_alloc: if (alloc_required) gfs2_alloc_put(dip); - out_gunlock: +out_gunlock: gfs2_glock_dq_m(2, ghs); - out: +out: gfs2_holder_uninit(ghs); gfs2_holder_uninit(ghs + 1); if (!error) { - atomic_inc(&inode->i_count); d_instantiate(dentry, inode); mark_inode_dirty(inode); } @@ -274,17 +272,12 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, static int gfs2_unlink(struct inode *dir, struct dentry *dentry) { - struct gfs2_inode *dip = dir->u.generic_ip; - struct gfs2_sbd *sdp = dip->i_sbd; - struct gfs2_inode *ip = dentry->d_inode->u.generic_ip; - struct gfs2_unlinked *ul; + struct gfs2_inode *dip = GFS2_I(dir); + struct gfs2_sbd *sdp = GFS2_SB(dir); + struct gfs2_inode *ip = GFS2_I(dentry->d_inode); struct gfs2_holder ghs[2]; int error; - error = gfs2_unlinked_get(sdp, &ul); - if (error) - return error; - gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1); @@ -296,24 +289,23 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry) if (error) goto out_gunlock; - error = gfs2_trans_begin(sdp, 2 * RES_DINODE + RES_LEAF + - RES_UNLINKED, 0); + error = gfs2_trans_begin(sdp, 2*RES_DINODE + RES_LEAF + RES_RG_BIT, 0); if (error) goto out_gunlock; - error = gfs2_unlinki(dip, &dentry->d_name, ip, ul); + error = gfs2_dir_del(dip, &dentry->d_name); + if (error) + goto out_end_trans; - gfs2_trans_end(sdp); + error = gfs2_change_nlink(ip, -1); - out_gunlock: +out_end_trans: + gfs2_trans_end(sdp); +out_gunlock: gfs2_glock_dq_m(2, ghs); - - out: +out: gfs2_holder_uninit(ghs); gfs2_holder_uninit(ghs + 1); - - gfs2_unlinked_put(sdp, ul); - return error; } @@ -329,8 +321,8 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry) static int gfs2_symlink(struct inode *dir, struct dentry *dentry, const char *symname) { - struct gfs2_inode *dip = dir->u.generic_ip, *ip; - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_inode *dip = GFS2_I(dir), *ip; + struct gfs2_sbd *sdp = GFS2_SB(dir); struct gfs2_holder ghs[2]; struct inode *inode; struct buffer_head *dibh; @@ -388,8 +380,8 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry, static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode) { - struct gfs2_inode *dip = dir->u.generic_ip, *ip; - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_inode *dip = GFS2_I(dir), *ip; + struct gfs2_sbd *sdp = GFS2_SB(dir); struct gfs2_holder ghs[2]; struct inode *inode; struct buffer_head *dibh; @@ -466,17 +458,12 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode) static int gfs2_rmdir(struct inode *dir, struct dentry *dentry) { - struct gfs2_inode *dip = dir->u.generic_ip; - struct gfs2_sbd *sdp = dip->i_sbd; - struct gfs2_inode *ip = dentry->d_inode->u.generic_ip; - struct gfs2_unlinked *ul; + struct gfs2_inode *dip = GFS2_I(dir); + struct gfs2_sbd *sdp = GFS2_SB(dir); + struct gfs2_inode *ip = GFS2_I(dentry->d_inode); struct gfs2_holder ghs[2]; int error; - error = gfs2_unlinked_get(sdp, &ul); - if (error) - return error; - gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1); @@ -499,12 +486,11 @@ static int gfs2_rmdir(struct inode *dir, struct dentry *dentry) goto out_gunlock; } - error = gfs2_trans_begin(sdp, 2 * RES_DINODE + 3 * RES_LEAF + - RES_UNLINKED, 0); + error = gfs2_trans_begin(sdp, 2 * RES_DINODE + 3 * RES_LEAF + RES_RG_BIT, 0); if (error) goto out_gunlock; - error = gfs2_rmdiri(dip, &dentry->d_name, ip, ul); + error = gfs2_rmdiri(dip, &dentry->d_name, ip); gfs2_trans_end(sdp); @@ -515,8 +501,6 @@ static int gfs2_rmdir(struct inode *dir, struct dentry *dentry) gfs2_holder_uninit(ghs); gfs2_holder_uninit(ghs + 1); - gfs2_unlinked_put(sdp, ul); - return error; } @@ -532,8 +516,8 @@ static int gfs2_rmdir(struct inode *dir, struct dentry *dentry) static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) { - struct gfs2_inode *dip = dir->u.generic_ip, *ip; - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_inode *dip = GFS2_I(dir), *ip; + struct gfs2_sbd *sdp = GFS2_SB(dir); struct gfs2_holder ghs[2]; struct inode *inode; struct buffer_head *dibh; @@ -600,12 +584,11 @@ static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, static int gfs2_rename(struct inode *odir, struct dentry *odentry, struct inode *ndir, struct dentry *ndentry) { - struct gfs2_inode *odip = odir->u.generic_ip; - struct gfs2_inode *ndip = ndir->u.generic_ip; - struct gfs2_inode *ip = odentry->d_inode->u.generic_ip; + struct gfs2_inode *odip = GFS2_I(odir); + struct gfs2_inode *ndip = GFS2_I(ndir); + struct gfs2_inode *ip = GFS2_I(odentry->d_inode); struct gfs2_inode *nip = NULL; - struct gfs2_sbd *sdp = odip->i_sbd; - struct gfs2_unlinked *ul; + struct gfs2_sbd *sdp = GFS2_SB(odir); struct gfs2_holder ghs[4], r_gh; unsigned int num_gh; int dir_rename = 0; @@ -614,15 +597,11 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, int error; if (ndentry->d_inode) { - nip = ndentry->d_inode->u.generic_ip; + nip = GFS2_I(ndentry->d_inode); if (ip == nip) return 0; } - error = gfs2_unlinked_get(sdp, &ul); - if (error) - return error; - /* Make sure we aren't trying to move a dirctory into it's subdir */ if (S_ISDIR(ip->i_di.di_mode) && odip != ndip) { @@ -743,14 +722,12 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + al->al_rgd->rd_ri.ri_length + 4 * RES_DINODE + 4 * RES_LEAF + - RES_UNLINKED + RES_STATFS + - RES_QUOTA, 0); + RES_STATFS + RES_QUOTA, 0); if (error) goto out_ipreserv; } else { error = gfs2_trans_begin(sdp, 4 * RES_DINODE + - 5 * RES_LEAF + - RES_UNLINKED, 0); + 5 * RES_LEAF, 0); if (error) goto out_gunlock; } @@ -759,9 +736,13 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, if (nip) { if (S_ISDIR(nip->i_di.di_mode)) - error = gfs2_rmdiri(ndip, &ndentry->d_name, nip, ul); - else - error = gfs2_unlinki(ndip, &ndentry->d_name, nip, ul); + error = gfs2_rmdiri(ndip, &ndentry->d_name, nip); + else { + error = gfs2_dir_del(ndip, &ndentry->d_name); + if (error) + goto out_end_trans; + error = gfs2_change_nlink(nip, -1); + } if (error) goto out_end_trans; } @@ -800,35 +781,26 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, if (error) goto out_end_trans; - out_end_trans: +out_end_trans: gfs2_trans_end(sdp); - - out_ipreserv: +out_ipreserv: if (alloc_required) gfs2_inplace_release(ndip); - - out_gunlock_q: +out_gunlock_q: if (alloc_required) gfs2_quota_unlock(ndip); - - out_alloc: +out_alloc: if (alloc_required) gfs2_alloc_put(ndip); - - out_gunlock: +out_gunlock: gfs2_glock_dq_m(num_gh, ghs); - - out_uninit: +out_uninit: for (x = 0; x < num_gh; x++) gfs2_holder_uninit(ghs + x); - - out_gunlock_r: +out_gunlock_r: if (dir_rename) gfs2_glock_dq_uninit(&r_gh); - - out: - gfs2_unlinked_put(sdp, ul); - +out: return error; } @@ -844,7 +816,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, static int gfs2_readlink(struct dentry *dentry, char __user *user_buf, int user_size) { - struct gfs2_inode *ip = dentry->d_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(dentry->d_inode); char array[GFS2_FAST_NAME_SIZE], *buf = array; unsigned int len = GFS2_FAST_NAME_SIZE; int error; @@ -880,7 +852,7 @@ static int gfs2_readlink(struct dentry *dentry, char __user *user_buf, static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd) { - struct gfs2_inode *ip = dentry->d_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(dentry->d_inode); char array[GFS2_FAST_NAME_SIZE], *buf = array; unsigned int len = GFS2_FAST_NAME_SIZE; int error; @@ -906,7 +878,7 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd) static int gfs2_permission(struct inode *inode, int mask, struct nameidata *nd) { - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_holder i_gh; int error; @@ -926,7 +898,7 @@ static int gfs2_permission(struct inode *inode, int mask, struct nameidata *nd) static int setattr_size(struct inode *inode, struct iattr *attr) { - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); int error; if (attr->ia_size != ip->i_di.di_size) { @@ -944,8 +916,8 @@ static int setattr_size(struct inode *inode, struct iattr *attr) static int setattr_chown(struct inode *inode, struct iattr *attr) { - struct gfs2_inode *ip = inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); struct buffer_head *dibh; uint32_t ouid, ogid, nuid, ngid; int error; @@ -1021,7 +993,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr) static int gfs2_setattr(struct dentry *dentry, struct iattr *attr) { struct inode *inode = dentry->d_inode; - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_holder i_gh; int error; @@ -1068,7 +1040,7 @@ static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) { struct inode *inode = dentry->d_inode; - struct gfs2_inode *ip = inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_holder gh; int error; @@ -1084,7 +1056,7 @@ static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, static int gfs2_setxattr(struct dentry *dentry, const char *name, const void *data, size_t size, int flags) { - struct gfs2_inode *ip = dentry->d_inode->u.generic_ip; + struct inode *inode = dentry->d_inode; struct gfs2_ea_request er; memset(&er, 0, sizeof(struct gfs2_ea_request)); @@ -1096,9 +1068,9 @@ static int gfs2_setxattr(struct dentry *dentry, const char *name, er.er_data_len = size; er.er_flags = flags; - gfs2_assert_warn(ip->i_sbd, !(er.er_flags & GFS2_ERF_MODE)); + gfs2_assert_warn(GFS2_SB(inode), !(er.er_flags & GFS2_ERF_MODE)); - return gfs2_ea_set(ip, &er); + return gfs2_ea_set(GFS2_I(inode), &er); } static ssize_t gfs2_getxattr(struct dentry *dentry, const char *name, @@ -1114,7 +1086,7 @@ static ssize_t gfs2_getxattr(struct dentry *dentry, const char *name, er.er_name_len = strlen(er.er_name); er.er_data_len = size; - return gfs2_ea_get(dentry->d_inode->u.generic_ip, &er); + return gfs2_ea_get(GFS2_I(dentry->d_inode), &er); } static ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size) @@ -1125,7 +1097,7 @@ static ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size) er.er_data = (size) ? buffer : NULL; er.er_data_len = size; - return gfs2_ea_list(dentry->d_inode->u.generic_ip, &er); + return gfs2_ea_list(GFS2_I(dentry->d_inode), &er); } static int gfs2_removexattr(struct dentry *dentry, const char *name) @@ -1138,7 +1110,7 @@ static int gfs2_removexattr(struct dentry *dentry, const char *name) return -EOPNOTSUPP; er.er_name_len = strlen(er.er_name); - return gfs2_ea_remove(dentry->d_inode->u.generic_ip, &er); + return gfs2_ea_remove(GFS2_I(dentry->d_inode), &er); } struct inode_operations gfs2_file_iops = { diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 1c17acc946f9bd..317d497f8f8899 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "gfs2.h" #include "lm_interface.h" @@ -36,6 +37,10 @@ #include "super.h" #include "sys.h" #include "util.h" +#include "trans.h" +#include "dir.h" +#include "eattr.h" +#include "bmap.h" /** * gfs2_write_inode - Make sure the inode is stable on the disk @@ -47,12 +52,15 @@ static int gfs2_write_inode(struct inode *inode, int sync) { - struct gfs2_inode *ip = inode->u.generic_ip; - - if (current->flags & PF_MEMALLOC) - return 0; - if (ip && sync) - gfs2_log_flush(ip->i_gl->gl_sbd, ip->i_gl); + struct gfs2_inode *ip = GFS2_I(inode); + + /* Check this is a "normal" inode */ + if (inode->u.generic_ip) { + if (current->flags & PF_MEMALLOC) + return 0; + if (sync) + gfs2_log_flush(ip->i_gl->gl_sbd, ip->i_gl); + } return 0; } @@ -78,7 +86,6 @@ static void gfs2_put_super(struct super_block *sb) gfs2_glock_dq_uninit(&sdp->sd_freeze_gh); mutex_unlock(&sdp->sd_freeze_lock); - kthread_stop(sdp->sd_inoded_process); kthread_stop(sdp->sd_quotad_process); kthread_stop(sdp->sd_logd_process); kthread_stop(sdp->sd_recoverd_process); @@ -110,11 +117,9 @@ static void gfs2_put_super(struct super_block *sb) gfs2_glock_dq_uninit(&sdp->sd_jinode_gh); gfs2_glock_dq_uninit(&sdp->sd_ir_gh); gfs2_glock_dq_uninit(&sdp->sd_sc_gh); - gfs2_glock_dq_uninit(&sdp->sd_ut_gh); gfs2_glock_dq_uninit(&sdp->sd_qc_gh); iput(sdp->sd_ir_inode); iput(sdp->sd_sc_inode); - iput(sdp->sd_ut_inode); iput(sdp->sd_qc_inode); } @@ -274,16 +279,20 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data) static void gfs2_clear_inode(struct inode *inode) { - struct gfs2_inode *ip = inode->u.generic_ip; - - if (ip) { - spin_lock(&ip->i_spin); - ip->i_vnode = NULL; - inode->u.generic_ip = NULL; - spin_unlock(&ip->i_spin); - + /* This tells us its a "real" inode and not one which only + * serves to contain an address space (see rgrp.c, meta_io.c) + * which therefore doesn't have its own glocks. + */ + if (inode->u.generic_ip) { + struct gfs2_inode *ip = GFS2_I(inode); + gfs2_glock_inode_squish(inode); + gfs2_assert(inode->i_sb->s_fs_info, ip->i_gl->gl_state == LM_ST_UNLOCKED); + ip->i_gl->gl_object = NULL; gfs2_glock_schedule_for_reclaim(ip->i_gl); - gfs2_inode_put(ip); + gfs2_glock_put(ip->i_gl); + ip->i_gl = NULL; + if (ip->i_iopen_gh.gh_gl) + gfs2_glock_dq_uninit(&ip->i_iopen_gh); } } @@ -361,6 +370,70 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) return 0; } +/* + * We have to (at the moment) hold the inodes main lock to cover + * the gap between unlocking the shared lock on the iopen lock and + * taking the exclusive lock. I'd rather do a shared -> exclusive + * conversion on the iopen lock, but we can change that later. This + * is safe, just less efficient. + */ +static void gfs2_delete_inode(struct inode *inode) +{ + struct gfs2_sbd *sdp = inode->i_sb->s_fs_info; + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_holder gh; + int error; + + if (!inode->u.generic_ip) + goto out; + + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &gh); + if (unlikely(error)) { + gfs2_glock_dq_uninit(&ip->i_iopen_gh); + goto out; + } + + gfs2_glock_dq(&ip->i_iopen_gh); + gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &ip->i_iopen_gh); + error = gfs2_glock_nq(&ip->i_iopen_gh); + if (error) + goto out_uninit; + + if (S_ISDIR(ip->i_di.di_mode) && + (ip->i_di.di_flags & GFS2_DIF_EXHASH)) { + error = gfs2_dir_exhash_dealloc(ip); + if (error) + goto out_unlock; + } + + if (ip->i_di.di_eattr) { + error = gfs2_ea_dealloc(ip); + if (error) + goto out_unlock; + } + + if (!gfs2_is_stuffed(ip)) { + error = gfs2_file_dealloc(ip); + if (error) + goto out_unlock; + } + + error = gfs2_dinode_dealloc(ip); + +out_unlock: + gfs2_glock_dq(&ip->i_iopen_gh); +out_uninit: + gfs2_holder_uninit(&ip->i_iopen_gh); + gfs2_glock_dq_uninit(&gh); + if (error) + fs_warn(sdp, "gfs2_delete_inode: %d\n", error); +out: + truncate_inode_pages(&inode->i_data, 0); + clear_inode(inode); +} + + + static struct inode *gfs2_alloc_inode(struct super_block *sb) { struct gfs2_sbd *sdp = sb->s_fs_info; @@ -370,8 +443,6 @@ static struct inode *gfs2_alloc_inode(struct super_block *sb) if (ip) { ip->i_flags = 0; ip->i_gl = NULL; - ip->i_sbd = sdp; - ip->i_vnode = &ip->i_inode; ip->i_greedy = gfs2_tune_get(sdp, gt_greedy_default); ip->i_last_pfault = jiffies; } @@ -387,6 +458,7 @@ struct super_operations gfs2_super_ops = { .alloc_inode = gfs2_alloc_inode, .destroy_inode = gfs2_destroy_inode, .write_inode = gfs2_write_inode, + .delete_inode = gfs2_delete_inode, .put_super = gfs2_put_super, .write_super = gfs2_write_super, .write_super_lockfs = gfs2_write_super_lockfs, diff --git a/fs/gfs2/ops_vm.c b/fs/gfs2/ops_vm.c index 263c1fb7bbafeb..08709f19ea9804 100644 --- a/fs/gfs2/ops_vm.c +++ b/fs/gfs2/ops_vm.c @@ -38,15 +38,15 @@ static void pfault_be_greedy(struct gfs2_inode *ip) ip->i_last_pfault = jiffies; spin_unlock(&ip->i_spin); - gfs2_inode_hold(ip); + igrab(&ip->i_inode); if (gfs2_glock_be_greedy(ip->i_gl, time)) - gfs2_inode_put(ip); + iput(&ip->i_inode); } static struct page *gfs2_private_nopage(struct vm_area_struct *area, unsigned long address, int *type) { - struct gfs2_inode *ip = area->vm_file->f_mapping->host->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(area->vm_file->f_mapping->host); struct gfs2_holder i_gh; struct page *result; int error; @@ -69,7 +69,7 @@ static struct page *gfs2_private_nopage(struct vm_area_struct *area, static int alloc_page_backing(struct gfs2_inode *ip, struct page *page) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); unsigned long index = page->index; uint64_t lblock = index << (PAGE_CACHE_SHIFT - sdp->sd_sb.sb_bsize_shift); @@ -114,7 +114,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page) unsigned int extlen; int new = 1; - error = gfs2_extent_map(ip->i_vnode, lblock, &new, &dblock, &extlen); + error = gfs2_extent_map(&ip->i_inode, lblock, &new, &dblock, &extlen); if (error) goto out_trans; @@ -142,7 +142,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page) static struct page *gfs2_sharewrite_nopage(struct vm_area_struct *area, unsigned long address, int *type) { - struct gfs2_inode *ip = area->vm_file->f_mapping->host->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(area->vm_file->f_mapping->host); struct gfs2_holder i_gh; struct page *result = NULL; unsigned long index = ((address - area->vm_start) >> PAGE_CACHE_SHIFT) + diff --git a/fs/gfs2/page.c b/fs/gfs2/page.c index cd93644c7d7052..a8165a693b56c1 100644 --- a/fs/gfs2/page.c +++ b/fs/gfs2/page.c @@ -38,20 +38,17 @@ void gfs2_pte_inval(struct gfs2_glock *gl) struct inode *inode; ip = gl->gl_object; + inode = &ip->i_inode; if (!ip || !S_ISREG(ip->i_di.di_mode)) return; if (!test_bit(GIF_PAGED, &ip->i_flags)) return; - inode = gfs2_ip2v_lookup(ip); - if (inode) { - unmap_shared_mapping_range(inode->i_mapping, 0, 0); - iput(inode); + unmap_shared_mapping_range(inode->i_mapping, 0, 0); - if (test_bit(GIF_SW_PAGED, &ip->i_flags)) - set_bit(GLF_DIRTY, &gl->gl_flags); - } + if (test_bit(GIF_SW_PAGED, &ip->i_flags)) + set_bit(GLF_DIRTY, &gl->gl_flags); clear_bit(GIF_SW_PAGED, &ip->i_flags); } @@ -68,19 +65,12 @@ void gfs2_page_inval(struct gfs2_glock *gl) struct inode *inode; ip = gl->gl_object; + inode = &ip->i_inode; if (!ip || !S_ISREG(ip->i_di.di_mode)) return; - inode = gfs2_ip2v_lookup(ip); - if (inode) { - struct address_space *mapping = inode->i_mapping; - - truncate_inode_pages(mapping, 0); - gfs2_assert_withdraw(ip->i_sbd, !mapping->nrpages); - - iput(inode); - } - + truncate_inode_pages(inode->i_mapping, 0); + gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), !inode->i_mapping->nrpages); clear_bit(GIF_PAGED, &ip->i_flags); } @@ -97,32 +87,30 @@ void gfs2_page_sync(struct gfs2_glock *gl, int flags) { struct gfs2_inode *ip; struct inode *inode; + struct address_space *mapping; + int error = 0; ip = gl->gl_object; + inode = &ip->i_inode; if (!ip || !S_ISREG(ip->i_di.di_mode)) return; - inode = gfs2_ip2v_lookup(ip); - if (inode) { - struct address_space *mapping = inode->i_mapping; - int error = 0; + mapping = inode->i_mapping; - if (flags & DIO_START) - filemap_fdatawrite(mapping); - if (!error && (flags & DIO_WAIT)) - error = filemap_fdatawait(mapping); + if (flags & DIO_START) + filemap_fdatawrite(mapping); + if (!error && (flags & DIO_WAIT)) + error = filemap_fdatawait(mapping); - /* Put back any errors cleared by filemap_fdatawait() - so they can be caught by someone who can pass them - up to user space. */ + /* Put back any errors cleared by filemap_fdatawait() + so they can be caught by someone who can pass them + up to user space. */ - if (error == -ENOSPC) - set_bit(AS_ENOSPC, &mapping->flags); - else if (error) - set_bit(AS_EIO, &mapping->flags); + if (error == -ENOSPC) + set_bit(AS_ENOSPC, &mapping->flags); + else if (error) + set_bit(AS_EIO, &mapping->flags); - iput(inode); - } } /** @@ -138,8 +126,8 @@ void gfs2_page_sync(struct gfs2_glock *gl, int flags) int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, uint64_t block, void *private) { - struct gfs2_sbd *sdp = ip->i_sbd; - struct inode *inode = ip->i_vnode; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); + struct inode *inode = &ip->i_inode; struct page *page = (struct page *)private; struct buffer_head *bh; int release = 0; @@ -193,8 +181,8 @@ int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, int gfs2_block_truncate_page(struct address_space *mapping) { struct inode *inode = mapping->host; - struct gfs2_inode *ip = inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); loff_t from = inode->i_size; unsigned long index = from >> PAGE_CACHE_SHIFT; unsigned offset = from & (PAGE_CACHE_SIZE-1); diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index f752b01846905f..d3cd5171d7c75a 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -248,7 +248,7 @@ static void slot_put(struct gfs2_quota_data *qd) static int bh_get(struct gfs2_quota_data *qd) { struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; - struct gfs2_inode *ip = sdp->sd_qc_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode); unsigned int block, offset; uint64_t dblock; int new = 0; @@ -266,7 +266,7 @@ static int bh_get(struct gfs2_quota_data *qd) block = qd->qd_slot / sdp->sd_qc_per_block; offset = qd->qd_slot % sdp->sd_qc_per_block;; - error = gfs2_block_map(ip->i_vnode, block, &new, &dblock, &boundary); + error = gfs2_block_map(&ip->i_inode, block, &new, &dblock, &boundary); if (error) goto fail; error = gfs2_meta_read(ip->i_gl, dblock, DIO_START | DIO_WAIT, &bh); @@ -444,7 +444,7 @@ static void qdsb_put(struct gfs2_quota_data *qd) int gfs2_quota_hold(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; struct gfs2_quota_data **qd = al->al_qd; int error; @@ -493,7 +493,7 @@ int gfs2_quota_hold(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) void gfs2_quota_unhold(struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; unsigned int x; @@ -531,7 +531,7 @@ static int sort_qd(const void *a, const void *b) static void do_qc(struct gfs2_quota_data *qd, int64_t change) { struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; - struct gfs2_inode *ip = sdp->sd_qc_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode); struct gfs2_quota_change *qc = qd->qd_bh_qc; int64_t x; @@ -578,7 +578,7 @@ static void do_qc(struct gfs2_quota_data *qd, int64_t change) static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc, int64_t change, struct gfs2_quota_data *qd) { - struct inode *inode = ip->i_vnode; + struct inode *inode = &ip->i_inode; struct address_space *mapping = inode->i_mapping; unsigned long index = loc >> PAGE_CACHE_SHIFT; unsigned offset = loc & (PAGE_CACHE_SHIFT - 1); @@ -647,7 +647,7 @@ unlock: static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) { struct gfs2_sbd *sdp = (*qda)->qd_gl->gl_sbd; - struct gfs2_inode *ip = sdp->sd_quota_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode); unsigned int data_blocks, ind_blocks; struct file_ra_state ra_state; struct gfs2_holder *ghs, i_gh; @@ -716,7 +716,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) goto out_gunlock; } - file_ra_state_init(&ra_state, ip->i_vnode->i_mapping); + file_ra_state_init(&ra_state, ip->i_inode.i_mapping); for (x = 0; x < num_qd; x++) { qd = qda[x]; offset = qd2offset(qd); @@ -758,7 +758,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, struct gfs2_holder *q_gh) { struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; - struct gfs2_inode *ip = sdp->sd_quota_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode); struct gfs2_holder i_gh; struct gfs2_quota q; char buf[sizeof(struct gfs2_quota)]; @@ -829,7 +829,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, int gfs2_quota_lock(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; unsigned int x; int error = 0; @@ -958,7 +958,7 @@ static int print_message(struct gfs2_quota_data *qd, char *type) int gfs2_quota_check(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; struct gfs2_quota_data *qd; int64_t value; @@ -1008,7 +1008,7 @@ void gfs2_quota_change(struct gfs2_inode *ip, int64_t change, unsigned int x; unsigned int found = 0; - if (gfs2_assert_warn(ip->i_sbd, change)) + if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), change)) return; if (ip->i_di.di_flags & GFS2_DIF_SYSTEM) return; @@ -1126,7 +1126,7 @@ int gfs2_quota_read(struct gfs2_sbd *sdp, int user, uint32_t id, int gfs2_quota_init(struct gfs2_sbd *sdp) { - struct gfs2_inode *ip = sdp->sd_qc_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode); unsigned int blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; unsigned int x, slot = 0; unsigned int found = 0; @@ -1162,7 +1162,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp) if (!extlen) { int new = 0; - error = gfs2_extent_map(ip->i_vnode, x, &new, &dblock, &extlen); + error = gfs2_extent_map(&ip->i_inode, x, &new, &dblock, &extlen); if (error) goto fail; } diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index c504ac1b831d05..7aabc03e4abdfc 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -32,14 +32,14 @@ int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk, struct buffer_head **bh) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(jd->jd_inode); struct gfs2_glock *gl = ip->i_gl; int new = 0; uint64_t dblock; uint32_t extlen; int error; - error = gfs2_extent_map(ip->i_vnode, blk, &new, &dblock, &extlen); + error = gfs2_extent_map(&ip->i_inode, blk, &new, &dblock, &extlen); if (error) return error; if (!dblock) { @@ -190,7 +190,7 @@ static int find_good_lh(struct gfs2_jdesc *jd, unsigned int *blk, *blk = 0; if (*blk == orig_blk) { - gfs2_consist_inode(jd->jd_inode->u.generic_ip); + gfs2_consist_inode(GFS2_I(jd->jd_inode)); return -EIO; } } @@ -224,7 +224,7 @@ static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head) continue; if (lh.lh_sequence == head->lh_sequence) { - gfs2_consist_inode(jd->jd_inode->u.generic_ip); + gfs2_consist_inode(GFS2_I(jd->jd_inode)); return -EIO; } if (lh.lh_sequence < head->lh_sequence) @@ -300,8 +300,7 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header *head) static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start, unsigned int end, int pass) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); struct buffer_head *bh; struct gfs2_log_descriptor *ld; int error = 0; @@ -330,7 +329,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start, continue; } if (error == 1) { - gfs2_consist_inode(jd->jd_inode->u.generic_ip); + gfs2_consist_inode(GFS2_I(jd->jd_inode)); error = -EIO; } brelse(bh); @@ -367,8 +366,8 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start, static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(jd->jd_inode); + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); unsigned int lblock; int new = 0; uint64_t dblock; @@ -380,7 +379,7 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head) lblock = head->lh_blkno; gfs2_replay_incr_blk(sdp, &lblock); - error = gfs2_block_map(ip->i_vnode, lblock, &new, &dblock, &boundary); + error = gfs2_block_map(&ip->i_inode, lblock, &new, &dblock, &boundary); if (error) return error; if (!dblock) { @@ -426,8 +425,8 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head) int gfs2_recover_journal(struct gfs2_jdesc *jd) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(jd->jd_inode); + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); struct gfs2_log_header head; struct gfs2_holder j_gh, ji_gh, t_gh; unsigned long t; diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 691e6f3ce43b7a..75df79eb50ba1c 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -34,17 +34,19 @@ /* * These routines are used by the resource group routines (rgrp.c) * to keep track of block allocation. Each block is represented by two - * bits. One bit indicates whether or not the block is used. (1=used, - * 0=free) The other bit indicates whether or not the block contains a - * dinode or not. (1=dinode, 0=not-dinode) So, each byte represents - * GFS2_NBBY (i.e. 4) blocks. + * bits. So, each byte represents GFS2_NBBY (i.e. 4) blocks. + * + * 0 = Free + * 1 = Used (not metadata) + * 2 = Unlinked (still in use) inode + * 3 = Used (metadata) */ static const char valid_change[16] = { /* current */ - /* n */ 0, 1, 0, 1, + /* n */ 0, 1, 1, 1, /* e */ 1, 0, 0, 0, - /* w */ 0, 0, 0, 0, + /* w */ 0, 0, 0, 1, 1, 0, 0, 0 }; @@ -228,26 +230,27 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) tmp = rgd->rd_ri.ri_data - rgd->rd_rg.rg_free - rgd->rd_rg.rg_dinodes; - if (count[1] != tmp) { + if (count[1] + count[2] != tmp) { if (gfs2_consist_rgrpd(rgd)) fs_err(sdp, "used data mismatch: %u != %u\n", count[1], tmp); return; } - if (count[2]) { + if (count[3] != rgd->rd_rg.rg_dinodes) { if (gfs2_consist_rgrpd(rgd)) - fs_err(sdp, "free metadata mismatch: %u != 0\n", - count[2]); + fs_err(sdp, "used metadata mismatch: %u != %u\n", + count[3], rgd->rd_rg.rg_dinodes); return; } - if (count[3] != rgd->rd_rg.rg_dinodes) { + if (count[2] > count[3]) { if (gfs2_consist_rgrpd(rgd)) - fs_err(sdp, "used metadata mismatch: %u != %u\n", - count[3], rgd->rd_rg.rg_dinodes); + fs_err(sdp, "unlinked inodes > inodes: %u\n", + count[2]); return; } + } static inline int rgrp_contains_block(struct gfs2_rindex *ri, uint64_t block) @@ -368,6 +371,9 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) uint32_t bytes_left, bytes; int x; + if (!length) + return -EINVAL; + rgd->rd_bits = kcalloc(length, sizeof(struct gfs2_bitmap), GFP_KERNEL); if (!rgd->rd_bits) return -ENOMEM; @@ -433,14 +439,16 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) static int gfs2_ri_update(struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = ip->i_sbd; - struct inode *inode = ip->i_vnode; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); + struct inode *inode = &ip->i_inode; struct gfs2_rgrpd *rgd; char buf[sizeof(struct gfs2_rindex)]; struct file_ra_state ra_state; uint64_t junk = ip->i_di.di_size; int error; + printk(KERN_INFO "gfs2_ri_update inode=%p\n", inode); + if (do_div(junk, sizeof(struct gfs2_rindex))) { gfs2_consist_inode(ip); return -EIO; @@ -448,9 +456,12 @@ static int gfs2_ri_update(struct gfs2_inode *ip) clear_rgrpdi(sdp); + printk(KERN_INFO "rgrps cleared\n"); + file_ra_state_init(&ra_state, inode->i_mapping); for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) { loff_t pos = sdp->sd_rgrps * sizeof(struct gfs2_rindex); + printk(KERN_INFO "reading rgrp %d\n", sdp->sd_rgrps); error = gfs2_internal_read(ip, &ra_state, buf, &pos, sizeof(struct gfs2_rindex)); if (!error) @@ -474,13 +485,15 @@ static int gfs2_ri_update(struct gfs2_inode *ip) list_add_tail(&rgd->rd_list_mru, &sdp->sd_rindex_mru_list); gfs2_rindex_in(&rgd->rd_ri, buf); - + printk(KERN_INFO "compute bitstructs\n"); error = compute_bitstructs(rgd); if (error) goto fail; + printk(KERN_INFO "gfs2_glock_get\n"); error = gfs2_glock_get(sdp, rgd->rd_ri.ri_addr, &gfs2_rgrp_glops, CREATE, &rgd->rd_gl); + printk(KERN_INFO "gfs2_glock_got one\n"); if (error) goto fail; @@ -488,13 +501,14 @@ static int gfs2_ri_update(struct gfs2_inode *ip) rgd->rd_rg_vn = rgd->rd_gl->gl_vn - 1; } + printk(KERN_INFO "ok, finished\n"); sdp->sd_rindex_vn = ip->i_gl->gl_vn; - return 0; - fail: +fail: + printk(KERN_INFO "fail\n"); clear_rgrpdi(sdp); - + printk(KERN_INFO "cleared rgrps\n"); return error; } @@ -518,7 +532,7 @@ static int gfs2_ri_update(struct gfs2_inode *ip) int gfs2_rindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ri_gh) { - struct gfs2_inode *ip = sdp->sd_rindex->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(sdp->sd_rindex); struct gfs2_glock *gl = ip->i_gl; int error; @@ -583,8 +597,7 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) error = gfs2_meta_reread(sdp, bi->bi_bh, DIO_WAIT); if (error) goto fail; - if (gfs2_metatype_check(sdp, bi->bi_bh, - (y) ? GFS2_METATYPE_RB : + if (gfs2_metatype_check(sdp, bi->bi_bh, y ? GFS2_METATYPE_RB : GFS2_METATYPE_RG)) { error = -EIO; goto fail; @@ -605,7 +618,7 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) return 0; - fail: +fail: while (x--) { bi = rgd->rd_bits + x; brelse(bi->bi_bh); @@ -667,8 +680,7 @@ void gfs2_rgrp_repolish_clones(struct gfs2_rgrpd *rgd) if (!bi->bi_clone) continue; memcpy(bi->bi_clone + bi->bi_offset, - bi->bi_bh->b_data + bi->bi_offset, - bi->bi_len); + bi->bi_bh->b_data + bi->bi_offset, bi->bi_len); } spin_lock(&sdp->sd_rindex_spin); @@ -757,13 +769,11 @@ static struct gfs2_rgrpd *recent_rgrp_first(struct gfs2_sbd *sdp, goto out; } - first: +first: rgd = list_entry(sdp->sd_rindex_recent_list.next, struct gfs2_rgrpd, rd_recent); - - out: +out: spin_unlock(&sdp->sd_rindex_spin); - return rgd; } @@ -805,9 +815,8 @@ static struct gfs2_rgrpd *recent_rgrp_next(struct gfs2_rgrpd *cur_rgd, if (!list_empty(head)) rgd = list_entry(head->next, struct gfs2_rgrpd, rd_recent); - out: +out: spin_unlock(&sdp->sd_rindex_spin); - return rgd; } @@ -835,7 +844,7 @@ static void recent_rgrp_add(struct gfs2_rgrpd *new_rgd) } list_add_tail(&new_rgd->rd_recent, &sdp->sd_rindex_recent_list); - out: +out: spin_unlock(&sdp->sd_rindex_spin); } @@ -898,7 +907,7 @@ static void forward_rgrp_set(struct gfs2_sbd *sdp, struct gfs2_rgrpd *rgd) static int get_local_rgrp(struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_rgrpd *rgd, *begin = NULL; struct gfs2_alloc *al = &ip->i_alloc; int flags = LM_FLAG_TRY; @@ -965,7 +974,7 @@ static int get_local_rgrp(struct gfs2_inode *ip) } } - out: +out: ip->i_last_rg_alloc = rgd->rd_ri.ri_addr; if (begin) { @@ -988,7 +997,7 @@ static int get_local_rgrp(struct gfs2_inode *ip) int gfs2_inplace_reserve_i(struct gfs2_inode *ip, char *file, unsigned int line) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; int error; @@ -1020,7 +1029,7 @@ int gfs2_inplace_reserve_i(struct gfs2_inode *ip, char *file, unsigned int line) void gfs2_inplace_release(struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; if (gfs2_assert_warn(sdp, al->al_alloced <= al->al_requested) == -1) @@ -1061,8 +1070,7 @@ unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, uint64_t block) gfs2_assert(rgd->rd_sbd, buf < length); buf_block = rgrp_block - bi->bi_start * GFS2_NBBY; - type = gfs2_testbit(rgd, - bi->bi_bh->b_data + bi->bi_offset, + type = gfs2_testbit(rgd, bi->bi_bh->b_data + bi->bi_offset, bi->bi_len, buf_block); return type; @@ -1210,7 +1218,7 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, uint64_t bstart, uint64_t gfs2_alloc_data(struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; struct gfs2_rgrpd *rgd = al->al_rgd; uint32_t goal, blk; @@ -1254,7 +1262,7 @@ uint64_t gfs2_alloc_data(struct gfs2_inode *ip) uint64_t gfs2_alloc_meta(struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; struct gfs2_rgrpd *rgd = al->al_rgd; uint32_t goal, blk; @@ -1299,7 +1307,7 @@ uint64_t gfs2_alloc_meta(struct gfs2_inode *ip) uint64_t gfs2_alloc_di(struct gfs2_inode *dip) { - struct gfs2_sbd *sdp = dip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); struct gfs2_alloc *al = &dip->i_alloc; struct gfs2_rgrpd *rgd = al->al_rgd; uint32_t blk; @@ -1341,7 +1349,7 @@ uint64_t gfs2_alloc_di(struct gfs2_inode *dip) void gfs2_free_data(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_rgrpd *rgd; rgd = rgblk_free(sdp, bstart, blen, GFS2_BLKST_FREE); @@ -1370,7 +1378,7 @@ void gfs2_free_data(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen) void gfs2_free_meta(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_rgrpd *rgd; rgd = rgblk_free(sdp, bstart, blen, GFS2_BLKST_FREE); @@ -1385,11 +1393,25 @@ void gfs2_free_meta(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen) gfs2_trans_add_rg(rgd); gfs2_statfs_change(sdp, 0, +blen, 0); - gfs2_quota_change(ip, -(int64_t)blen, - ip->i_di.di_uid, ip->i_di.di_gid); + gfs2_quota_change(ip, -(int64_t)blen, ip->i_di.di_uid, ip->i_di.di_gid); gfs2_meta_wipe(ip, bstart, blen); } +void gfs2_unlink_di(struct inode *inode) +{ + struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_sbd *sdp = GFS2_SB(inode); + struct gfs2_rgrpd *rgd; + u64 blkno = ip->i_num.no_addr; + + rgd = rgblk_free(sdp, blkno, 1, GFS2_BLKST_UNLINKED); + if (!rgd) + return; + gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); + gfs2_rgrp_out(&rgd->rd_rg, rgd->rd_bits[0].bi_bh->b_data); + gfs2_trans_add_rg(rgd); +} + void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, uint64_t blkno) { struct gfs2_sbd *sdp = rgd->rd_sbd; @@ -1412,12 +1434,6 @@ void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, uint64_t blkno) gfs2_trans_add_rg(rgd); } -/** - * gfs2_free_uninit_di - free a dinode block - * @rgd: the resource group that contains the dinode - * @ip: the inode - * - */ void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip) { diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h index d2db3719cc0f17..e86a532cc1594a 100644 --- a/fs/gfs2/rgrp.h +++ b/fs/gfs2/rgrp.h @@ -45,6 +45,7 @@ void gfs2_free_data(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen); void gfs2_free_meta(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen); void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, uint64_t blkno); void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip); +void gfs2_unlink_di(struct inode *inode); struct gfs2_rgrp_list { unsigned int rl_rgrps; diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index a943a505bc5ab6..f2d287660cc941 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -31,7 +31,6 @@ #include "rgrp.h" #include "super.h" #include "trans.h" -#include "unlinked.h" #include "util.h" /** @@ -55,7 +54,6 @@ void gfs2_tune_init(struct gfs2_tune *gt) gt->gt_recoverd_secs = 60; gt->gt_logd_secs = 1; gt->gt_quotad_secs = 5; - gt->gt_inoded_secs = 15; gt->gt_quota_simul_sync = 64; gt->gt_quota_warn_period = 10; gt->gt_quota_scale_num = 1; @@ -202,9 +200,6 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) sdp->sd_hash_bsize = sdp->sd_sb.sb_bsize / 2; sdp->sd_hash_bsize_shift = sdp->sd_sb.sb_bsize_shift - 1; sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(uint64_t); - sdp->sd_ut_per_block = (sdp->sd_sb.sb_bsize - - sizeof(struct gfs2_meta_header)) / - sizeof(struct gfs2_unlinked_tag); sdp->sd_qc_per_block = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header)) / sizeof(struct gfs2_quota_change); @@ -277,7 +272,7 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh) { - struct gfs2_inode *dip = sdp->sd_jindex->u.generic_ip; + struct gfs2_inode *dip = GFS2_I(sdp->sd_jindex); struct qstr name; char buf[20]; struct gfs2_jdesc *jd; @@ -296,8 +291,7 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh) name.len = sprintf(buf, "journal%u", sdp->sd_journals); name.hash = gfs2_disk_hash(name.name, name.len); - error = gfs2_dir_search(sdp->sd_jindex, - &name, NULL, NULL); + error = gfs2_dir_search(sdp->sd_jindex, &name, NULL, NULL); if (error == -ENOENT) { error = 0; break; @@ -423,22 +417,19 @@ struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp) int gfs2_jdesc_check(struct gfs2_jdesc *jd) { - struct gfs2_inode *ip = jd->jd_inode->u.generic_ip; - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_inode *ip = GFS2_I(jd->jd_inode); + struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); int ar; int error; - if (ip->i_di.di_size < (8 << 20) || - ip->i_di.di_size > (1 << 30) || + if (ip->i_di.di_size < (8 << 20) || ip->i_di.di_size > (1 << 30) || (ip->i_di.di_size & (sdp->sd_sb.sb_bsize - 1))) { gfs2_consist_inode(ip); return -EIO; } jd->jd_blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; - error = gfs2_write_alloc_required(ip, - 0, ip->i_di.di_size, - &ar); + error = gfs2_write_alloc_required(ip, 0, ip->i_di.di_size, &ar); if (!error && ar) { gfs2_consist_inode(ip); error = -EIO; @@ -456,7 +447,7 @@ int gfs2_jdesc_check(struct gfs2_jdesc *jd) int gfs2_make_fs_rw(struct gfs2_sbd *sdp) { - struct gfs2_inode *ip = sdp->sd_jdesc->jd_inode->u.generic_ip; + struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode); struct gfs2_glock *j_gl = ip->i_gl; struct gfs2_holder t_gh; struct gfs2_log_header head; @@ -484,9 +475,6 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp) sdp->sd_log_sequence = head.lh_sequence + 1; gfs2_log_pointers_init(sdp, head.lh_blkno); - error = gfs2_unlinked_init(sdp); - if (error) - goto fail; error = gfs2_quota_init(sdp); if (error) goto fail_unlinked; @@ -498,7 +486,6 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp) return 0; fail_unlinked: - gfs2_unlinked_cleanup(sdp); fail: t_gh.gh_flags |= GL_NOCACHE; @@ -519,7 +506,6 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp) struct gfs2_holder t_gh; int error; - gfs2_unlinked_dealloc(sdp); gfs2_quota_sync(sdp); gfs2_statfs_sync(sdp); @@ -537,7 +523,6 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp) if (t_gh.gh_gl) gfs2_glock_dq_uninit(&t_gh); - gfs2_unlinked_cleanup(sdp); gfs2_quota_cleanup(sdp); return error; @@ -545,9 +530,9 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp) int gfs2_statfs_init(struct gfs2_sbd *sdp) { - struct gfs2_inode *m_ip = sdp->sd_statfs_inode->u.generic_ip; + struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master; - struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip; + struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode); struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; struct buffer_head *m_bh, *l_bh; struct gfs2_holder gh; @@ -594,7 +579,7 @@ int gfs2_statfs_init(struct gfs2_sbd *sdp) void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free, int64_t dinodes) { - struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip; + struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode); struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; struct buffer_head *l_bh; int error; @@ -620,8 +605,8 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free, int gfs2_statfs_sync(struct gfs2_sbd *sdp) { - struct gfs2_inode *m_ip = sdp->sd_statfs_inode->u.generic_ip; - struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip; + struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); + struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode); struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master; struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; struct gfs2_holder gh; @@ -852,10 +837,8 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, error = -ENOMEM; goto out; } - ip = jd->jd_inode->u.generic_ip; - error = gfs2_glock_nq_init(ip->i_gl, - LM_ST_SHARED, 0, - &lfcc->gh); + ip = GFS2_I(jd->jd_inode); + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &lfcc->gh); if (error) { kfree(lfcc); goto out; diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index d32a2c54daee45..3c4cb455890573 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c @@ -453,7 +453,6 @@ TUNE_ATTR_DAEMON(scand_secs, scand_process); TUNE_ATTR_DAEMON(recoverd_secs, recoverd_process); TUNE_ATTR_DAEMON(logd_secs, logd_process); TUNE_ATTR_DAEMON(quotad_secs, quotad_process); -TUNE_ATTR_DAEMON(inoded_secs, inoded_process); TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store); static struct attribute *tune_attrs[] = { @@ -485,7 +484,6 @@ static struct attribute *tune_attrs[] = { &tune_attr_recoverd_secs.attr, &tune_attr_logd_secs.attr, &tune_attr_quotad_secs.attr, - &tune_attr_inoded_secs.attr, &tune_attr_quota_scale.attr, &tune_attr_new_files_jdata.attr, &tune_attr_new_files_directio.attr, diff --git a/fs/gfs2/trans.h b/fs/gfs2/trans.h index 60ef163dd9bb94..fbef3f5a99e3e8 100644 --- a/fs/gfs2/trans.h +++ b/fs/gfs2/trans.h @@ -17,7 +17,6 @@ #define RES_LEAF 1 #define RES_RG_BIT 2 #define RES_EATTR 1 -#define RES_UNLINKED 1 #define RES_STATFS 1 #define RES_QUOTA 2 diff --git a/fs/gfs2/unlinked.c b/fs/gfs2/unlinked.c deleted file mode 100644 index b92d730020553a..00000000000000 --- a/fs/gfs2/unlinked.c +++ /dev/null @@ -1,459 +0,0 @@ -/* - * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. - * - * This copyrighted material is made available to anyone wishing to use, - * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "gfs2.h" -#include "lm_interface.h" -#include "incore.h" -#include "bmap.h" -#include "inode.h" -#include "meta_io.h" -#include "trans.h" -#include "unlinked.h" -#include "util.h" - -static int munge_ondisk(struct gfs2_sbd *sdp, unsigned int slot, - struct gfs2_unlinked_tag *ut) -{ - struct gfs2_inode *ip = sdp->sd_ut_inode->u.generic_ip; - unsigned int block, offset; - uint64_t dblock; - int new = 0; - struct buffer_head *bh; - int error; - int boundary; - - block = slot / sdp->sd_ut_per_block; - offset = slot % sdp->sd_ut_per_block; - - error = gfs2_block_map(ip->i_vnode, block, &new, &dblock, &boundary); - if (error) - return error; - error = gfs2_meta_read(ip->i_gl, dblock, DIO_START | DIO_WAIT, &bh); - if (error) - return error; - if (gfs2_metatype_check(sdp, bh, GFS2_METATYPE_UT)) { - error = -EIO; - goto out; - } - - mutex_lock(&sdp->sd_unlinked_mutex); - gfs2_trans_add_bh(ip->i_gl, bh, 1); - gfs2_unlinked_tag_out(ut, bh->b_data + - sizeof(struct gfs2_meta_header) + - offset * sizeof(struct gfs2_unlinked_tag)); - mutex_unlock(&sdp->sd_unlinked_mutex); - - out: - brelse(bh); - - return error; -} - -static void ul_hash(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul) -{ - spin_lock(&sdp->sd_unlinked_spin); - list_add(&ul->ul_list, &sdp->sd_unlinked_list); - gfs2_assert(sdp, ul->ul_count); - ul->ul_count++; - atomic_inc(&sdp->sd_unlinked_count); - spin_unlock(&sdp->sd_unlinked_spin); -} - -static void ul_unhash(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul) -{ - spin_lock(&sdp->sd_unlinked_spin); - list_del_init(&ul->ul_list); - gfs2_assert(sdp, ul->ul_count > 1); - ul->ul_count--; - gfs2_assert_warn(sdp, atomic_read(&sdp->sd_unlinked_count) > 0); - atomic_dec(&sdp->sd_unlinked_count); - spin_unlock(&sdp->sd_unlinked_spin); -} - -static struct gfs2_unlinked *ul_fish(struct gfs2_sbd *sdp) -{ - struct list_head *head; - struct gfs2_unlinked *ul; - int found = 0; - - if (sdp->sd_vfs->s_flags & MS_RDONLY) - return NULL; - - spin_lock(&sdp->sd_unlinked_spin); - - head = &sdp->sd_unlinked_list; - - list_for_each_entry(ul, head, ul_list) { - if (test_bit(ULF_LOCKED, &ul->ul_flags)) - continue; - - list_move_tail(&ul->ul_list, head); - ul->ul_count++; - set_bit(ULF_LOCKED, &ul->ul_flags); - found = 1; - - break; - } - - if (!found) - ul = NULL; - - spin_unlock(&sdp->sd_unlinked_spin); - - return ul; -} - -/** - * enforce_limit - limit the number of inodes waiting to be deallocated - * @sdp: the filesystem - * - * Returns: errno - */ - -static void enforce_limit(struct gfs2_sbd *sdp) -{ - unsigned int tries = 0, min = 0; - int error; - - if (atomic_read(&sdp->sd_unlinked_count) < - gfs2_tune_get(sdp, gt_ilimit)) - return; - - tries = gfs2_tune_get(sdp, gt_ilimit_tries); - min = gfs2_tune_get(sdp, gt_ilimit_min); - - while (tries--) { - struct gfs2_unlinked *ul = ul_fish(sdp); - if (!ul) - break; - error = gfs2_inode_dealloc(sdp, ul); - gfs2_unlinked_put(sdp, ul); - - if (!error) { - if (!--min) - break; - } else if (error != 1) - break; - } -} - -static struct gfs2_unlinked *ul_alloc(struct gfs2_sbd *sdp) -{ - struct gfs2_unlinked *ul; - - ul = kzalloc(sizeof(struct gfs2_unlinked), GFP_KERNEL); - if (ul) { - INIT_LIST_HEAD(&ul->ul_list); - ul->ul_count = 1; - set_bit(ULF_LOCKED, &ul->ul_flags); - } - - return ul; -} - -int gfs2_unlinked_get(struct gfs2_sbd *sdp, struct gfs2_unlinked **ul) -{ - unsigned int c, o = 0, b; - unsigned char byte = 0; - - enforce_limit(sdp); - - *ul = ul_alloc(sdp); - if (!*ul) - return -ENOMEM; - - spin_lock(&sdp->sd_unlinked_spin); - - for (c = 0; c < sdp->sd_unlinked_chunks; c++) - for (o = 0; o < PAGE_SIZE; o++) { - byte = sdp->sd_unlinked_bitmap[c][o]; - if (byte != 0xFF) - goto found; - } - - goto fail; - -found: - for (b = 0; b < 8; b++) - if (!(byte & (1 << b))) - break; - (*ul)->ul_slot = c * (8 * PAGE_SIZE) + o * 8 + b; - - if ((*ul)->ul_slot >= sdp->sd_unlinked_slots) - goto fail; - - sdp->sd_unlinked_bitmap[c][o] |= 1 << b; - - spin_unlock(&sdp->sd_unlinked_spin); - - return 0; - -fail: - spin_unlock(&sdp->sd_unlinked_spin); - kfree(*ul); - return -ENOSPC; -} - -void gfs2_unlinked_put(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul) -{ - gfs2_assert_warn(sdp, test_and_clear_bit(ULF_LOCKED, &ul->ul_flags)); - - spin_lock(&sdp->sd_unlinked_spin); - gfs2_assert(sdp, ul->ul_count); - ul->ul_count--; - if (!ul->ul_count) { - gfs2_icbit_munge(sdp, sdp->sd_unlinked_bitmap, ul->ul_slot, 0); - spin_unlock(&sdp->sd_unlinked_spin); - kfree(ul); - } else - spin_unlock(&sdp->sd_unlinked_spin); -} - -int gfs2_unlinked_ondisk_add(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul) -{ - int error; - - gfs2_assert_warn(sdp, test_bit(ULF_LOCKED, &ul->ul_flags)); - gfs2_assert_warn(sdp, list_empty(&ul->ul_list)); - - error = munge_ondisk(sdp, ul->ul_slot, &ul->ul_ut); - if (!error) - ul_hash(sdp, ul); - - return error; -} - -int gfs2_unlinked_ondisk_munge(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul) -{ - int error; - - gfs2_assert_warn(sdp, test_bit(ULF_LOCKED, &ul->ul_flags)); - gfs2_assert_warn(sdp, !list_empty(&ul->ul_list)); - - error = munge_ondisk(sdp, ul->ul_slot, &ul->ul_ut); - - return error; -} - -int gfs2_unlinked_ondisk_rm(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul) -{ - struct gfs2_unlinked_tag ut; - int error; - - gfs2_assert_warn(sdp, test_bit(ULF_LOCKED, &ul->ul_flags)); - gfs2_assert_warn(sdp, !list_empty(&ul->ul_list)); - - memset(&ut, 0, sizeof(struct gfs2_unlinked_tag)); - - error = munge_ondisk(sdp, ul->ul_slot, &ut); - if (error) - return error; - - ul_unhash(sdp, ul); - - return 0; -} - -/** - * gfs2_unlinked_dealloc - Go through the list of inodes to be deallocated - * @sdp: the filesystem - * - * Returns: errno - */ - -int gfs2_unlinked_dealloc(struct gfs2_sbd *sdp) -{ - unsigned int hits, strikes; - int error; - - for (;;) { - hits = 0; - strikes = 0; - - for (;;) { - struct gfs2_unlinked *ul = ul_fish(sdp); - if (!ul) - return 0; - error = gfs2_inode_dealloc(sdp, ul); - gfs2_unlinked_put(sdp, ul); - - if (!error) { - hits++; - if (strikes) - strikes--; - } else if (error == 1) { - strikes++; - if (strikes >= - atomic_read(&sdp->sd_unlinked_count)) { - error = 0; - break; - } - } else - return error; - } - - if (!hits || kthread_should_stop()) - break; - - cond_resched(); - } - - return 0; -} - -int gfs2_unlinked_init(struct gfs2_sbd *sdp) -{ - struct gfs2_inode *ip = sdp->sd_ut_inode->u.generic_ip; - unsigned int blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; - unsigned int x, slot = 0; - unsigned int found = 0; - uint64_t dblock; - uint32_t extlen = 0; - int error; - - if (!ip->i_di.di_size || - ip->i_di.di_size > (64 << 20) || - ip->i_di.di_size & (sdp->sd_sb.sb_bsize - 1)) { - gfs2_consist_inode(ip); - return -EIO; - } - sdp->sd_unlinked_slots = blocks * sdp->sd_ut_per_block; - sdp->sd_unlinked_chunks = DIV_ROUND_UP(sdp->sd_unlinked_slots, - 8 * PAGE_SIZE); - - error = -ENOMEM; - - sdp->sd_unlinked_bitmap = kcalloc(sdp->sd_unlinked_chunks, - sizeof(unsigned char *), - GFP_KERNEL); - if (!sdp->sd_unlinked_bitmap) - return error; - - for (x = 0; x < sdp->sd_unlinked_chunks; x++) { - sdp->sd_unlinked_bitmap[x] = kzalloc(PAGE_SIZE, GFP_KERNEL); - if (!sdp->sd_unlinked_bitmap[x]) - goto fail; - } - - for (x = 0; x < blocks; x++) { - struct buffer_head *bh; - unsigned int y; - - if (!extlen) { - int new = 0; - error = gfs2_extent_map(ip->i_vnode, x, &new, &dblock, &extlen); - if (error) - goto fail; - } - gfs2_meta_ra(ip->i_gl, dblock, extlen); - error = gfs2_meta_read(ip->i_gl, dblock, DIO_START | DIO_WAIT, - &bh); - if (error) - goto fail; - error = -EIO; - if (gfs2_metatype_check(sdp, bh, GFS2_METATYPE_UT)) { - brelse(bh); - goto fail; - } - - for (y = 0; - y < sdp->sd_ut_per_block && slot < sdp->sd_unlinked_slots; - y++, slot++) { - struct gfs2_unlinked_tag ut; - struct gfs2_unlinked *ul; - - gfs2_unlinked_tag_in(&ut, bh->b_data + - sizeof(struct gfs2_meta_header) + - y * sizeof(struct gfs2_unlinked_tag)); - if (!ut.ut_inum.no_addr) - continue; - - error = -ENOMEM; - ul = ul_alloc(sdp); - if (!ul) { - brelse(bh); - goto fail; - } - ul->ul_ut = ut; - ul->ul_slot = slot; - - spin_lock(&sdp->sd_unlinked_spin); - gfs2_icbit_munge(sdp, sdp->sd_unlinked_bitmap, slot, 1); - spin_unlock(&sdp->sd_unlinked_spin); - ul_hash(sdp, ul); - - gfs2_unlinked_put(sdp, ul); - found++; - } - - brelse(bh); - dblock++; - extlen--; - } - - if (found) - fs_info(sdp, "found %u unlinked inodes\n", found); - - return 0; - -fail: - gfs2_unlinked_cleanup(sdp); - return error; -} - -/** - * gfs2_unlinked_cleanup - get rid of any extra struct gfs2_unlinked structures - * @sdp: the filesystem - * - */ - -void gfs2_unlinked_cleanup(struct gfs2_sbd *sdp) -{ - struct list_head *head = &sdp->sd_unlinked_list; - struct gfs2_unlinked *ul; - unsigned int x; - - spin_lock(&sdp->sd_unlinked_spin); - while (!list_empty(head)) { - ul = list_entry(head->next, struct gfs2_unlinked, ul_list); - - if (ul->ul_count > 1) { - list_move_tail(&ul->ul_list, head); - spin_unlock(&sdp->sd_unlinked_spin); - schedule(); - spin_lock(&sdp->sd_unlinked_spin); - continue; - } - - list_del_init(&ul->ul_list); - atomic_dec(&sdp->sd_unlinked_count); - - gfs2_assert_warn(sdp, ul->ul_count == 1); - gfs2_assert_warn(sdp, !test_bit(ULF_LOCKED, &ul->ul_flags)); - kfree(ul); - } - spin_unlock(&sdp->sd_unlinked_spin); - - gfs2_assert_warn(sdp, !atomic_read(&sdp->sd_unlinked_count)); - - if (sdp->sd_unlinked_bitmap) { - for (x = 0; x < sdp->sd_unlinked_chunks; x++) - kfree(sdp->sd_unlinked_bitmap[x]); - kfree(sdp->sd_unlinked_bitmap); - } -} - diff --git a/fs/gfs2/unlinked.h b/fs/gfs2/unlinked.h deleted file mode 100644 index 159cf5ffe47e4e..00000000000000 --- a/fs/gfs2/unlinked.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. - * - * This copyrighted material is made available to anyone wishing to use, - * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. - */ - -#ifndef __UNLINKED_DOT_H__ -#define __UNLINKED_DOT_H__ - -int gfs2_unlinked_get(struct gfs2_sbd *sdp, struct gfs2_unlinked **ul); -void gfs2_unlinked_put(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul); - -int gfs2_unlinked_ondisk_add(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul); -int gfs2_unlinked_ondisk_munge(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul); -int gfs2_unlinked_ondisk_rm(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul); - -int gfs2_unlinked_dealloc(struct gfs2_sbd *sdp); - -int gfs2_unlinked_init(struct gfs2_sbd *sdp); -void gfs2_unlinked_cleanup(struct gfs2_sbd *sdp); - -#endif /* __UNLINKED_DOT_H__ */ diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c index 88974e9824f7a0..39e67b1ec70ab7 100644 --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c @@ -109,7 +109,7 @@ int gfs2_consist_i(struct gfs2_sbd *sdp, int cluster_wide, const char *function, int gfs2_consist_inode_i(struct gfs2_inode *ip, int cluster_wide, const char *function, char *file, unsigned int line) { - struct gfs2_sbd *sdp = ip->i_sbd; + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); int rv; rv = gfs2_lm_withdraw(sdp, "GFS2: fsid=%s: fatal: filesystem consistency error\n" diff --git a/include/linux/gfs2_ondisk.h b/include/linux/gfs2_ondisk.h index 3893aac4e3ae33..1181da8319394e 100644 --- a/include/linux/gfs2_ondisk.h +++ b/include/linux/gfs2_ondisk.h @@ -1,11 +1,11 @@ /* -* Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. -* -* This copyrighted material is made available to anyone wishing to use, -* modify, copy, or redistribute it subject to the terms and conditions -* of the GNU General Public License v.2. -*/ + * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + */ #ifndef __GFS2_ONDISK_DOT_H__ #define __GFS2_ONDISK_DOT_H__ @@ -36,7 +36,6 @@ #define GFS2_FORMAT_LB 1000 #define GFS2_FORMAT_EA 1600 #define GFS2_FORMAT_ED 1700 -#define GFS2_FORMAT_UT 1300 #define GFS2_FORMAT_QC 1400 /* These are format numbers for entities contained in files */ #define GFS2_FORMAT_RI 1100 @@ -80,7 +79,6 @@ static inline int gfs2_inum_equal(const struct gfs2_inum *ino1, #define GFS2_METATYPE_LB 12 #define GFS2_METATYPE_EA 10 #define GFS2_METATYPE_ED 11 -#define GFS2_METATYPE_UT 13 #define GFS2_METATYPE_QC 14 struct gfs2_meta_header { @@ -158,7 +156,7 @@ struct gfs2_rindex { #define GFS2_BLKST_FREE 0 #define GFS2_BLKST_USED 1 -#define GFS2_BLKST_INVALID 2 +#define GFS2_BLKST_UNLINKED 2 #define GFS2_BLKST_DINODE 3 #define GFS2_RGF_JOURNAL 0x00000001 @@ -396,20 +394,6 @@ struct gfs2_statfs_change { __be64 sc_dinodes; }; -/* - * Unlinked Tag - * Describes an allocated inode that isn't linked into - * the directory tree and might need to be deallocated. - */ - -#define GFS2_UTF_UNINIT 0x00000001 - -struct gfs2_unlinked_tag { - struct gfs2_inum ut_inum; - __be32 ut_flags; /* GFS2_UTF_... */ - __u32 __pad; -}; - /* * Quota change * Describes an allocation change for a particular @@ -445,8 +429,6 @@ extern void gfs2_inum_range_in(struct gfs2_inum_range *ir, char *buf); extern void gfs2_inum_range_out(struct gfs2_inum_range *ir, char *buf); extern void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, char *buf); extern void gfs2_statfs_change_out(struct gfs2_statfs_change *sc, char *buf); -extern void gfs2_unlinked_tag_in(struct gfs2_unlinked_tag *ut, char *buf); -extern void gfs2_unlinked_tag_out(struct gfs2_unlinked_tag *ut, char *buf); extern void gfs2_quota_change_in(struct gfs2_quota_change *qc, char *buf); /* Printing functions */ -- cgit 1.2.3-korg From af18ddb8864b096e3ed4732e2d4b21c956dcfe3a Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Sat, 24 Jun 2006 15:42:21 -0400 Subject: [GFS2] Eliminate one instance of __GFP_NOFAIL This removes one instance of GFP_NOFAIL from the glock callback function. It also fixes a bug where a , was used at a line end rather than ; causing unintended results. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 8 +++++--- fs/gfs2/ops_inode.c | 6 ++---- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 35bac90878a588..dbeb4ad836bd76 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -416,7 +416,7 @@ void gfs2_holder_uninit(struct gfs2_holder *gh) * @gl: the glock * @state: the state we're requesting * @flags: the modifier flags - * @gfp_flags: __GFP_NOFAIL + * @gfp_flags: * * Figure out how big an impact this function has. Either: * 1) Replace it with a cache of structures hanging off the struct gfs2_sbd @@ -720,6 +720,7 @@ static void gfs2_glmutex_unlock(struct gfs2_glock *gl) * @gl: the glock * @state: the state the caller wants us to change to * + * Note: This may fail sliently if we are out of memory. */ static void handle_callback(struct gfs2_glock *gl, unsigned int state) @@ -744,8 +745,9 @@ restart: } else { spin_unlock(&gl->gl_spin); - new_gh = gfs2_holder_get(gl, state, LM_FLAG_TRY, - GFP_KERNEL | __GFP_NOFAIL), + new_gh = gfs2_holder_get(gl, state, LM_FLAG_TRY, GFP_KERNEL); + if (!new_gh) + return; set_bit(HIF_DEMOTE, &new_gh->gh_iflags); set_bit(HIF_DEALLOC, &new_gh->gh_iflags); diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 5d5ebbcba534ba..8895baafc64077 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -962,10 +962,8 @@ static int setattr_chown(struct inode *inode, struct iattr *attr) brelse(dibh); if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) { - gfs2_quota_change(ip, -ip->i_di.di_blocks, - ouid, ogid); - gfs2_quota_change(ip, ip->i_di.di_blocks, - nuid, ngid); + gfs2_quota_change(ip, -ip->i_di.di_blocks, ouid, ogid); + gfs2_quota_change(ip, ip->i_di.di_blocks, nuid, ngid); } out_end_trans: -- cgit 1.2.3-korg From 627add2d1385394d020c84533c91ad26bc37b166 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 5 Jul 2006 13:16:19 -0400 Subject: [GFS2] Correct logic in glock scanner Under certain circumstances the glock scanning logic would demote locks which ought not to have been selected for demotion. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index dbeb4ad836bd76..7f362d0c3f7aac 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1967,8 +1967,11 @@ static void scan_glock(struct gfs2_glock *gl) if (gfs2_glmutex_trylock(gl)) { if (gl->gl_ops == &gfs2_inode_glops) { struct gfs2_inode *ip = gl->gl_object; - if (ip) + if (ip == NULL) { + struct gfs2_sbd *sdp = gl->gl_sbd; + gfs2_assert_withdraw(sdp, gl->gl_state == LM_ST_UNLOCKED); goto out_schedule; + } } if (queue_empty(gl, &gl->gl_holders) && gl->gl_state != LM_ST_UNLOCKED && @@ -1982,7 +1985,7 @@ static void scan_glock(struct gfs2_glock *gl) return; - out_schedule: +out_schedule: gfs2_glmutex_unlock(gl); gfs2_glock_schedule_for_reclaim(gl); gfs2_glock_put(gl); -- cgit 1.2.3-korg From 29937ac6caa68d60c7f1a3e07b6137cf53e09e24 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Thu, 6 Jul 2006 17:58:03 -0400 Subject: [GFS2] Fixes to scanning of glocks (again) This really is the correct fix this time. We just ignore all glocks associated with inodes until the inodes are pushed from the inode cache. At that point the glocks are queued for reclaim, so we don't need to do it here. Also fix one or two other minor bugs. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 12 +++--------- fs/gfs2/inode.c | 2 ++ fs/gfs2/ops_inode.c | 1 + fs/gfs2/page.c | 3 +-- 4 files changed, 7 insertions(+), 11 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 7f362d0c3f7aac..0381d4cc414641 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1965,19 +1965,13 @@ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, static void scan_glock(struct gfs2_glock *gl) { if (gfs2_glmutex_trylock(gl)) { - if (gl->gl_ops == &gfs2_inode_glops) { - struct gfs2_inode *ip = gl->gl_object; - if (ip == NULL) { - struct gfs2_sbd *sdp = gl->gl_sbd; - gfs2_assert_withdraw(sdp, gl->gl_state == LM_ST_UNLOCKED); - goto out_schedule; - } - } + if (gl->gl_ops == &gfs2_inode_glops) + goto out; if (queue_empty(gl, &gl->gl_holders) && gl->gl_state != LM_ST_UNLOCKED && demote_ok(gl)) goto out_schedule; - +out: gfs2_glmutex_unlock(gl); } diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 6499c4f9107829..f4c48395208a0b 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -325,6 +325,7 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff) uint32_t nlink; int error; + BUG_ON(ip->i_di.di_nlink != ip->i_inode.i_nlink); nlink = ip->i_di.di_nlink + diff; /* If we are reducing the nlink count, but the new value ends up being @@ -341,6 +342,7 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff) ip->i_di.di_nlink = nlink; ip->i_di.di_ctime = get_seconds(); + ip->i_inode.i_nlink = nlink; gfs2_trans_add_bh(ip->i_gl, dibh, 1); gfs2_dinode_out(&ip->i_di, dibh->b_data); diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 8895baafc64077..caecafe0469ba1 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -250,6 +250,7 @@ out: gfs2_holder_uninit(ghs + 1); if (!error) { + atomic_inc(&inode->i_count); d_instantiate(dentry, inode); mark_inode_dirty(inode); } diff --git a/fs/gfs2/page.c b/fs/gfs2/page.c index a8165a693b56c1..b93caf294b9f49 100644 --- a/fs/gfs2/page.c +++ b/fs/gfs2/page.c @@ -256,8 +256,7 @@ void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page, struct buffer_head *bh; unsigned int start, end; - for (bh = head, start = 0; - bh != head || !start; + for (bh = head, start = 0; bh != head || !start; bh = bh->b_this_page, start = end) { end = start + bsize; if (end <= from || start >= to) -- cgit 1.2.3-korg From f45b7ddd2bae1dc98e35c3611b55cba6d2a8da9e Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Thu, 27 Jul 2006 13:53:53 -0400 Subject: [GFS2] Use a bio to read the superblock This means that we don't need to create a special inode just to contain a struct address_space in order to read a single disk block. Instead we read the disk block directly. Its slightly faster, and uses slightly less memory, but the real reason for doing this is that it removes a special case from the glock code. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 3 +-- fs/gfs2/glops.c | 22 +++-------------- fs/gfs2/ops_fstype.c | 5 ---- fs/gfs2/super.c | 69 ++++++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 64 insertions(+), 35 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 0381d4cc414641..91ac9c9d4a9658 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -311,8 +311,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, /* If this glock protects actual on-disk data or metadata blocks, create a VFS inode to manage the pages/buffers holding them. */ if (glops == &gfs2_inode_glops || - glops == &gfs2_rgrp_glops || - glops == &gfs2_meta_glops) { + glops == &gfs2_rgrp_glops) { gl->gl_aspace = gfs2_aspace_get(sdp); if (!gl->gl_aspace) { error = -ENOMEM; diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 3f909a81a07124..75d4c50cff45cf 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -156,18 +156,6 @@ static void meta_go_inval(struct gfs2_glock *gl, int flags) gl->gl_vn++; } -/** - * meta_go_demote_ok - Check to see if it's ok to unlock a glock - * @gl: the glock - * - * Returns: 1 if we have no cached data; ok to demote meta glock - */ - -static int meta_go_demote_ok(struct gfs2_glock *gl) -{ - return !gl->gl_aspace->i_mapping->nrpages; -} - /** * inode_go_xmote_th - promote/demote a glock * @gl: the glock @@ -338,11 +326,12 @@ static void inode_go_unlock(struct gfs2_holder *gh) struct gfs2_glock *gl = gh->gh_gl; struct gfs2_inode *ip = gl->gl_object; - if (ip && test_bit(GLF_DIRTY, &gl->gl_flags)) - gfs2_inode_attr_in(ip); + if (ip) { + if (test_bit(GLF_DIRTY, &gl->gl_flags)) + gfs2_inode_attr_in(ip); - if (ip) gfs2_meta_cache_flush(ip); + } } /** @@ -507,9 +496,6 @@ static int quota_go_demote_ok(struct gfs2_glock *gl) struct gfs2_glock_operations gfs2_meta_glops = { .go_xmote_th = gfs2_glock_xmote_th, .go_drop_th = gfs2_glock_drop_th, - .go_sync = meta_go_sync, - .go_inval = meta_go_inval, - .go_demote_ok = meta_go_demote_ok, .go_type = LM_TYPE_META }; diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index a86ce67949db2f..de18923eea708f 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -310,11 +310,6 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo) sdp->sd_sb.sb_bsize, (unsigned int)PAGE_SIZE); goto out; } - - /* Get rid of buffers from the original block size */ - sb_gh.gh_gl->gl_ops->go_inval(sb_gh.gh_gl, DIO_METADATA | DIO_DATA); - sb_gh.gh_gl->gl_aspace->i_blkbits = sdp->sd_sb.sb_bsize_shift; - sb_set_blocksize(sb, sdp->sd_sb.sb_bsize); /* Get the root inode */ diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index f2d287660cc941..48fd4cb49c1e43 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "gfs2.h" #include "lm_interface.h" @@ -157,6 +158,54 @@ int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent) return 0; } + +static int end_bio_io_page(struct bio *bio, unsigned int bytes_done, int error) +{ + struct page *page = bio->bi_private; + if (bio->bi_size) + return 1; + + if (!error) + SetPageUptodate(page); + unlock_page(page); + return 0; +} + +static struct page *gfs2_read_super(struct super_block *sb, sector_t sector) +{ + struct page *page; + struct bio *bio; + + page = alloc_page(GFP_KERNEL); + if (unlikely(!page)) + return NULL; + + ClearPageUptodate(page); + ClearPageDirty(page); + lock_page(page); + + bio = bio_alloc(GFP_KERNEL, 1); + if (unlikely(!bio)) { + __free_page(page); + return NULL; + } + + bio->bi_sector = sector; + bio->bi_bdev = sb->s_bdev; + bio_add_page(bio, page, PAGE_SIZE, 0); + + bio->bi_end_io = end_bio_io_page; + bio->bi_private = page; + submit_bio(READ | BIO_RW_SYNC, bio); + wait_on_page_locked(page); + bio_put(bio); + if (!PageUptodate(page)) { + __free_page(page); + return NULL; + } + return page; +} + /** * gfs2_read_sb - Read super block * @sdp: The GFS2 superblock @@ -167,23 +216,23 @@ int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent) int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) { - struct buffer_head *bh; uint32_t hash_blocks, ind_blocks, leaf_blocks; uint32_t tmp_blocks; unsigned int x; int error; + struct page *page; + char *sb; - error = gfs2_meta_read(gl, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift, - DIO_FORCE | DIO_START | DIO_WAIT, &bh); - if (error) { + page = gfs2_read_super(sdp->sd_vfs, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift); + if (!page) { if (!silent) fs_err(sdp, "can't read superblock\n"); - return error; + return -EIO; } - - gfs2_assert(sdp, sizeof(struct gfs2_sb) <= bh->b_size); - gfs2_sb_in(&sdp->sd_sb, bh->b_data); - brelse(bh); + sb = kmap(page); + gfs2_sb_in(&sdp->sd_sb, sb); + kunmap(page); + __free_page(page); error = gfs2_check_sb(sdp, &sdp->sd_sb, silent); if (error) @@ -202,7 +251,7 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(uint64_t); sdp->sd_qc_per_block = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header)) / - sizeof(struct gfs2_quota_change); + sizeof(struct gfs2_quota_change); /* Compute maximum reservation required to add a entry to a directory */ -- cgit 1.2.3-korg From 5dd9feafb351a8bf304292623cbc63335c34d279 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Fri, 28 Jul 2006 14:52:33 -0400 Subject: [GFS2] Fix bug in clear_inode We should have been waiting for lock demotion to finish in clear_inode. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 1 + 1 file changed, 1 insertion(+) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 91ac9c9d4a9658..b6edf7c0923bc8 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -771,6 +771,7 @@ void gfs2_glock_inode_squish(struct inode *inode) list_add_tail(&gh.gh_list, &gl->gl_waiters2); run_queue(gl); spin_unlock(&gl->gl_spin); + wait_for_completion(&gh.gh_wait); gfs2_holder_uninit(&gh); } -- cgit 1.2.3-korg From 8872187780f6104216c67e7b60c11f708b513c38 Mon Sep 17 00:00:00 2001 From: Russell Cattelan Date: Thu, 10 Aug 2006 11:08:40 -0500 Subject: [GFS2] Fix a couple of refcount leaks. recovery.c add a brelse to deal with gfs2_replay_read_block being called twice on the same block. add a dput to drop the ref count on the root inode. This was causing lingering glocks and thus causing a mount failure to hang. Fix a endian conversion macro that was was swizzling 16bits when it should have been swizzling 32. Signed-off-by: Russell Cattelan Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 9 ++++++--- fs/gfs2/ops_fstype.c | 4 ++++ fs/gfs2/recovery.c | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index b6edf7c0923bc8..a5e16e5399995c 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -2167,7 +2167,9 @@ static int dump_glock(struct gfs2_glock *gl) spin_lock(&gl->gl_spin); - printk(KERN_INFO "Glock (%u, %llu)\n", gl->gl_name.ln_type, + printk(KERN_INFO "Glock 0x%p (%u, %llu)\n", + gl, + gl->gl_name.ln_type, (unsigned long long)gl->gl_name.ln_number); printk(KERN_INFO " gl_flags ="); for (x = 0; x < 32; x++) @@ -2187,8 +2189,9 @@ static int dump_glock(struct gfs2_glock *gl) printk(KERN_INFO " reclaim = %s\n", (list_empty(&gl->gl_reclaim)) ? "no" : "yes"); if (gl->gl_aspace) - printk(KERN_INFO " aspace = %lu\n", - gl->gl_aspace->i_mapping->nrpages); + printk(KERN_INFO " aspace = 0x%p nrpages = %lu\n", + gl->gl_aspace, + gl->gl_aspace->i_mapping->nrpages); else printk(KERN_INFO " aspace = no\n"); printk(KERN_INFO " ail = %d\n", atomic_read(&gl->gl_ail_count)); diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index de18923eea708f..444000968cf4c7 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -279,6 +279,10 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo) int error = 0; if (undo) { + if (sb->s_root) { + dput(sb->s_root); + sb->s_root = NULL; + } return 0; } diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index bbd44a4b1a1f15..8fe518cfb3de0c 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -325,6 +325,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start, error = get_log_header(jd, start, &lh); if (!error) { gfs2_replay_incr_blk(sdp, &start); + brelse(bh); continue; } if (error == 1) { @@ -396,7 +397,7 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head) lh = (struct gfs2_log_header *)bh->b_data; memset(lh, 0, sizeof(struct gfs2_log_header)); lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC); - lh->lh_header.mh_type = cpu_to_be16(GFS2_METATYPE_LH); + lh->lh_header.mh_type = cpu_to_be32(GFS2_METATYPE_LH); lh->lh_header.mh_format = cpu_to_be32(GFS2_FORMAT_LH); lh->lh_sequence = cpu_to_be64(head->lh_sequence + 1); lh->lh_flags = cpu_to_be32(GFS2_LOG_HEAD_UNMOUNT); -- cgit 1.2.3-korg From a2242db0906445491d9ac50bfa756b0de0a25d45 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Thu, 24 Aug 2006 17:03:05 -0400 Subject: [GFS2] Speed up scanning of glocks I noticed the gfs2_scand seemed to be taking a lot of CPU, so in order to cut that down a bit, here is a patch. Firstly the type of a glock is a constant during its lifetime, so that its possible to check this without needing locking. I've moved the (common) case of testing for an inode glock outside of the glmutex lock. Also there was a mutex left over from when the glock cache was master of the inode cache. That isn't required any more so I've removed that too. There is probably scope for further speed ups in the future in this area. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 24 +++++------------------- fs/gfs2/incore.h | 1 - fs/gfs2/ops_fstype.c | 1 - 3 files changed, 5 insertions(+), 21 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index a5e16e5399995c..005788fb361f9b 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -150,12 +150,9 @@ static void kill_glock(struct kref *kref) int gfs2_glock_put(struct gfs2_glock *gl) { - struct gfs2_sbd *sdp = gl->gl_sbd; struct gfs2_gl_hash_bucket *bucket = gl->gl_bucket; int rv = 0; - mutex_lock(&sdp->sd_invalidate_inodes_mutex); - write_lock(&bucket->hb_lock); if (kref_put(&gl->gl_ref, kill_glock)) { list_del_init(&gl->gl_list); @@ -166,8 +163,7 @@ int gfs2_glock_put(struct gfs2_glock *gl) goto out; } write_unlock(&bucket->hb_lock); - out: - mutex_unlock(&sdp->sd_invalidate_inodes_mutex); +out: return rv; } @@ -1964,19 +1960,18 @@ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, static void scan_glock(struct gfs2_glock *gl) { + if (gl->gl_ops == &gfs2_inode_glops) + goto out; + if (gfs2_glmutex_trylock(gl)) { - if (gl->gl_ops == &gfs2_inode_glops) - goto out; if (queue_empty(gl, &gl->gl_holders) && gl->gl_state != LM_ST_UNLOCKED && demote_ok(gl)) goto out_schedule; -out: gfs2_glmutex_unlock(gl); } - +out: gfs2_glock_put(gl); - return; out_schedule: @@ -2070,16 +2065,7 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait) t = jiffies; } - /* invalidate_inodes() requires that the sb inodes list - not change, but an async completion callback for an - unlock can occur which does glock_put() which - can call iput() which will change the sb inodes list. - invalidate_inodes_mutex prevents glock_put()'s during - an invalidate_inodes() */ - - mutex_lock(&sdp->sd_invalidate_inodes_mutex); invalidate_inodes(sdp->sd_vfs); - mutex_unlock(&sdp->sd_invalidate_inodes_mutex); msleep(10); } } diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index e98c14f30daa5e..78d3cb511eb878 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -507,7 +507,6 @@ struct gfs2_sbd { struct gfs2_holder sd_live_gh; struct gfs2_glock *sd_rename_gl; struct gfs2_glock *sd_trans_gl; - struct mutex sd_invalidate_inodes_mutex; /* Inode Stuff */ diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 444000968cf4c7..c66067c84bcfe9 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -63,7 +63,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb) INIT_LIST_HEAD(&sdp->sd_reclaim_list); spin_lock_init(&sdp->sd_reclaim_lock); init_waitqueue_head(&sdp->sd_reclaim_wq); - mutex_init(&sdp->sd_invalidate_inodes_mutex); mutex_init(&sdp->sd_inum_mutex); spin_lock_init(&sdp->sd_statfs_spin); -- cgit 1.2.3-korg From 8638460540749ddb1beca9e9a68d655a6fe6df65 Mon Sep 17 00:00:00 2001 From: Abhijith Das Date: Fri, 25 Aug 2006 11:13:37 -0500 Subject: [GFS2] Allow mounting of gfs2 and gfs2meta at the same time This patch allows the simultaneous mounting of gfs2meta and gfs2 filesystems. A restriction however is that a gfs2meta fs may only be mounted if its corresponding gfs2 filesystem is also mounted. Also, a gfs2 filesystem cannot be unmounted before its gfs2meta filesystem. Signed-off-by: Abhijith Das Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 6 +++ fs/gfs2/incore.h | 2 + fs/gfs2/ops_fstype.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++++-- fs/gfs2/ops_super.c | 3 ++ 4 files changed, 155 insertions(+), 3 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 005788fb361f9b..ef713dbff60126 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1165,7 +1165,13 @@ static void add_to_queue(struct gfs2_holder *gh) existing = find_holder_by_owner(&gl->gl_holders, gh->gh_owner); if (existing) { print_symbol(KERN_WARNING "original: %s\n", existing->gh_ip); + printk(KERN_INFO "pid : %d\n", existing->gh_owner->pid); + printk(KERN_INFO "lock type : %d lock state : %d\n", + existing->gh_gl->gl_name.ln_type, existing->gh_gl->gl_state); print_symbol(KERN_WARNING "new: %s\n", gh->gh_ip); + printk(KERN_INFO "pid : %d\n", gh->gh_owner->pid); + printk(KERN_INFO "lock type : %d lock state : %d\n", + gl->gl_name.ln_type, gl->gl_state); BUG(); } diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 78d3cb511eb878..77f0903d2f3ebb 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -472,6 +472,7 @@ enum { struct gfs2_sbd { struct super_block *sd_vfs; + struct super_block *sd_vfs_meta; struct kobject sd_kobj; unsigned long sd_flags; /* SDF_... */ struct gfs2_sb sd_sb; @@ -652,6 +653,7 @@ struct gfs2_sbd { /* Debugging crud */ unsigned long sd_last_warning; + struct vfsmount *sd_gfs2mnt; }; #endif /* __INCORE_DOT_H__ */ diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index c66067c84bcfe9..e5a91ead250cac 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include #include "gfs2.h" @@ -813,7 +815,138 @@ static int fill_super(struct super_block *sb, void *data, int silent) static int gfs2_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct vfsmount *mnt) { - return get_sb_bdev(fs_type, flags, dev_name, data, fill_super, mnt); + struct super_block *sb; + struct gfs2_sbd *sdp; + int error = get_sb_bdev(fs_type, flags, dev_name, data, fill_super, mnt); + if (error) + goto out; + sb = mnt->mnt_sb; + sdp = (struct gfs2_sbd*)sb->s_fs_info; + sdp->sd_gfs2mnt = mnt; +out: + return error; +} + +static int fill_super_meta(struct super_block *sb, struct super_block *new, + void *data, int silent) +{ + struct gfs2_sbd *sdp = sb->s_fs_info; + struct inode *inode; + int error = 0; + + new->s_fs_info = sdp; + sdp->sd_vfs_meta = sb; + + init_vfs(new, SDF_NOATIME); + + /* Get the master inode */ + inode = igrab(sdp->sd_master_dir); + + new->s_root = d_alloc_root(inode); + if (!new->s_root) { + fs_err(sdp, "can't get root dentry\n"); + error = -ENOMEM; + iput(inode); + } + new->s_root->d_op = &gfs2_dops; + + return error; +} +static int set_bdev_super(struct super_block *s, void *data) +{ + s->s_bdev = data; + s->s_dev = s->s_bdev->bd_dev; + return 0; +} + +static int test_bdev_super(struct super_block *s, void *data) +{ + return (void *)s->s_bdev == data; +} + +static struct super_block* get_gfs2_sb(const char *dev_name) +{ + struct kstat stat; + struct nameidata nd; + struct file_system_type *fstype; + struct super_block *sb = NULL, *s; + struct list_head *l; + int error; + + error = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); + if (error) { + printk(KERN_WARNING "GFS2: path_lookup on %s returned error\n", + dev_name); + goto out; + } + error = vfs_getattr(nd.mnt, nd.dentry, &stat); + + fstype = get_fs_type("gfs2"); + list_for_each(l, &fstype->fs_supers) { + s = list_entry(l, struct super_block, s_instances); + if ((S_ISBLK(stat.mode) && s->s_dev == stat.rdev) || + (S_ISDIR(stat.mode) && s == nd.dentry->d_inode->i_sb)) { + sb = s; + goto free_nd; + } + } + + printk(KERN_WARNING "GFS2: Unrecognized block device or " + "mount point %s", dev_name); + +free_nd: + path_release(&nd); +out: + return sb; +} + +static int gfs2_get_sb_meta(struct file_system_type *fs_type, int flags, + const char *dev_name, void *data, struct vfsmount *mnt) +{ + int error = 0; + struct super_block *sb = NULL, *new; + struct gfs2_sbd *sdp; + char *gfs2mnt = NULL; + + sb = get_gfs2_sb(dev_name); + if (!sb) { + printk(KERN_WARNING "GFS2: gfs2 mount does not exist\n"); + error = -ENOENT; + goto error; + } + sdp = (struct gfs2_sbd*) sb->s_fs_info; + if (sdp->sd_vfs_meta) { + printk(KERN_WARNING "GFS2: gfs2meta mount already exists\n"); + error = -EBUSY; + goto error; + } + mutex_lock(&sb->s_bdev->bd_mount_mutex); + new = sget(fs_type, test_bdev_super, set_bdev_super, sb->s_bdev); + mutex_unlock(&sb->s_bdev->bd_mount_mutex); + if (IS_ERR(new)) { + error = PTR_ERR(new); + goto error; + } + module_put(fs_type->owner); + new->s_flags = flags; + strlcpy(new->s_id, sb->s_id, sizeof(new->s_id)); + sb_set_blocksize(new, sb->s_blocksize); + error = fill_super_meta(sb, new, data, flags & MS_SILENT ? 1 : 0); + if (error) { + up_write(&new->s_umount); + deactivate_super(new); + goto error; + } + + new->s_flags |= MS_ACTIVE; + + /* Grab a reference to the gfs2 mount point */ + atomic_inc(&sdp->sd_gfs2mnt->mnt_count); + return simple_set_mnt(mnt, new); +error: + if (gfs2mnt) + kfree(gfs2mnt); + return error; } static void gfs2_kill_sb(struct super_block *sb) @@ -821,6 +954,14 @@ static void gfs2_kill_sb(struct super_block *sb) kill_block_super(sb); } +static void gfs2_kill_sb_meta(struct super_block *sb) +{ + struct gfs2_sbd *sdp = sb->s_fs_info; + generic_shutdown_super(sb); + sdp->sd_vfs_meta = NULL; + atomic_dec(&sdp->sd_gfs2mnt->mnt_count); +} + struct file_system_type gfs2_fs_type = { .name = "gfs2", .fs_flags = FS_REQUIRES_DEV, @@ -832,8 +973,8 @@ struct file_system_type gfs2_fs_type = { struct file_system_type gfs2meta_fs_type = { .name = "gfs2meta", .fs_flags = FS_REQUIRES_DEV, - .get_sb = gfs2_get_sb, - .kill_sb = gfs2_kill_sb, + .get_sb = gfs2_get_sb_meta, + .kill_sb = gfs2_kill_sb_meta, .owner = THIS_MODULE, }; diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 2e392c994ab111..18ed18c729e81e 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -78,6 +78,9 @@ static void gfs2_put_super(struct super_block *sb) if (!sdp) return; + if (!strncmp(sb->s_type->name, "gfs2meta", 8)) + return; /* meta fs. don't do nothin' */ + /* Unfreeze the filesystem, if we need to */ mutex_lock(&sdp->sd_freeze_lock); -- cgit 1.2.3-korg From 8fb4b536e7b9dbaf7a6b8204e887b92a14e4352c Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 30 Aug 2006 09:30:00 -0400 Subject: [GFS2] Make glock operations const For all the usual reasons of enforcing correctness and potentially reducing code size, this patch makes the glock operations const. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 30 +++++++++++++++--------------- fs/gfs2/glock.h | 6 +++--- fs/gfs2/glops.c | 18 +++++++++--------- fs/gfs2/glops.h | 18 +++++++++--------- fs/gfs2/incore.h | 4 ++-- 5 files changed, 38 insertions(+), 38 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index ef713dbff60126..709e6e0914fdca 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -253,7 +253,7 @@ static struct gfs2_glock *gfs2_glock_find(struct gfs2_sbd *sdp, */ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, - struct gfs2_glock_operations *glops, int create, + const struct gfs2_glock_operations *glops, int create, struct gfs2_glock **glp) { struct lm_lockname name; @@ -480,7 +480,7 @@ static int rq_promote(struct gfs2_holder *gh) { struct gfs2_glock *gl = gh->gh_gl; struct gfs2_sbd *sdp = gl->gl_sbd; - struct gfs2_glock_operations *glops = gl->gl_ops; + const struct gfs2_glock_operations *glops = gl->gl_ops; if (!relaxed_state_ok(gl->gl_state, gh->gh_state, gh->gh_flags)) { if (list_empty(&gl->gl_holders)) { @@ -535,7 +535,7 @@ static int rq_promote(struct gfs2_holder *gh) static int rq_demote(struct gfs2_holder *gh) { struct gfs2_glock *gl = gh->gh_gl; - struct gfs2_glock_operations *glops = gl->gl_ops; + const struct gfs2_glock_operations *glops = gl->gl_ops; if (!list_empty(&gl->gl_holders)) return 1; @@ -805,7 +805,7 @@ static void state_change(struct gfs2_glock *gl, unsigned int new_state) static void xmote_bh(struct gfs2_glock *gl, unsigned int ret) { struct gfs2_sbd *sdp = gl->gl_sbd; - struct gfs2_glock_operations *glops = gl->gl_ops; + const struct gfs2_glock_operations *glops = gl->gl_ops; struct gfs2_holder *gh = gl->gl_req_gh; int prev_state = gl->gl_state; int op_done = 1; @@ -915,7 +915,7 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret) void gfs2_glock_xmote_th(struct gfs2_glock *gl, unsigned int state, int flags) { struct gfs2_sbd *sdp = gl->gl_sbd; - struct gfs2_glock_operations *glops = gl->gl_ops; + const struct gfs2_glock_operations *glops = gl->gl_ops; int lck_flags = flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB | LM_FLAG_NOEXP | LM_FLAG_ANY | LM_FLAG_PRIORITY); @@ -960,7 +960,7 @@ void gfs2_glock_xmote_th(struct gfs2_glock *gl, unsigned int state, int flags) static void drop_bh(struct gfs2_glock *gl, unsigned int ret) { struct gfs2_sbd *sdp = gl->gl_sbd; - struct gfs2_glock_operations *glops = gl->gl_ops; + const struct gfs2_glock_operations *glops = gl->gl_ops; struct gfs2_holder *gh = gl->gl_req_gh; clear_bit(GLF_PREFETCH, &gl->gl_flags); @@ -1010,7 +1010,7 @@ static void drop_bh(struct gfs2_glock *gl, unsigned int ret) void gfs2_glock_drop_th(struct gfs2_glock *gl) { struct gfs2_sbd *sdp = gl->gl_sbd; - struct gfs2_glock_operations *glops = gl->gl_ops; + const struct gfs2_glock_operations *glops = gl->gl_ops; unsigned int ret; gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags)); @@ -1081,7 +1081,7 @@ static int glock_wait_internal(struct gfs2_holder *gh) { struct gfs2_glock *gl = gh->gh_gl; struct gfs2_sbd *sdp = gl->gl_sbd; - struct gfs2_glock_operations *glops = gl->gl_ops; + const struct gfs2_glock_operations *glops = gl->gl_ops; if (test_bit(HIF_ABORTED, &gh->gh_iflags)) return -EIO; @@ -1294,7 +1294,7 @@ int gfs2_glock_wait(struct gfs2_holder *gh) void gfs2_glock_dq(struct gfs2_holder *gh) { struct gfs2_glock *gl = gh->gh_gl; - struct gfs2_glock_operations *glops = gl->gl_ops; + const struct gfs2_glock_operations *glops = gl->gl_ops; if (gh->gh_flags & GL_SYNC) set_bit(GLF_SYNC, &gl->gl_flags); @@ -1339,7 +1339,7 @@ void gfs2_glock_dq(struct gfs2_holder *gh) static void gfs2_glock_prefetch(struct gfs2_glock *gl, unsigned int state, int flags) { - struct gfs2_glock_operations *glops = gl->gl_ops; + const struct gfs2_glock_operations *glops = gl->gl_ops; spin_lock(&gl->gl_spin); @@ -1365,7 +1365,7 @@ static void greedy_work(void *data) struct greedy *gr = data; struct gfs2_holder *gh = &gr->gr_gh; struct gfs2_glock *gl = gh->gh_gl; - struct gfs2_glock_operations *glops = gl->gl_ops; + const struct gfs2_glock_operations *glops = gl->gl_ops; clear_bit(GLF_SKIP_WAITERS2, &gl->gl_flags); @@ -1447,8 +1447,8 @@ void gfs2_glock_dq_uninit(struct gfs2_holder *gh) */ int gfs2_glock_nq_num(struct gfs2_sbd *sdp, uint64_t number, - struct gfs2_glock_operations *glops, unsigned int state, - int flags, struct gfs2_holder *gh) + const struct gfs2_glock_operations *glops, + unsigned int state, int flags, struct gfs2_holder *gh) { struct gfs2_glock *gl; int error; @@ -1645,7 +1645,7 @@ void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs) */ void gfs2_glock_prefetch_num(struct gfs2_sbd *sdp, uint64_t number, - struct gfs2_glock_operations *glops, + const struct gfs2_glock_operations *glops, unsigned int state, int flags) { struct gfs2_glock *gl; @@ -1827,7 +1827,7 @@ void gfs2_iopen_go_callback(struct gfs2_glock *io_gl, unsigned int state) static int demote_ok(struct gfs2_glock *gl) { struct gfs2_sbd *sdp = gl->gl_sbd; - struct gfs2_glock_operations *glops = gl->gl_ops; + const struct gfs2_glock_operations *glops = gl->gl_ops; int demote = 1; if (test_bit(GLF_STICKY, &gl->gl_flags)) diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index fdf58db44ae3dc..12bdbfee4ddcbd 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -75,7 +75,7 @@ static inline int gfs2_glock_is_blocking(struct gfs2_glock *gl) } int gfs2_glock_get(struct gfs2_sbd *sdp, - uint64_t number, struct gfs2_glock_operations *glops, + uint64_t number, const struct gfs2_glock_operations *glops, int create, struct gfs2_glock **glp); void gfs2_glock_hold(struct gfs2_glock *gl); int gfs2_glock_put(struct gfs2_glock *gl); @@ -97,7 +97,7 @@ int gfs2_glock_be_greedy(struct gfs2_glock *gl, unsigned int time); void gfs2_glock_dq_uninit(struct gfs2_holder *gh); int gfs2_glock_nq_num(struct gfs2_sbd *sdp, - uint64_t number, struct gfs2_glock_operations *glops, + uint64_t number, const struct gfs2_glock_operations *glops, unsigned int state, int flags, struct gfs2_holder *gh); int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs); @@ -105,7 +105,7 @@ void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs); void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs); void gfs2_glock_prefetch_num(struct gfs2_sbd *sdp, uint64_t number, - struct gfs2_glock_operations *glops, + const struct gfs2_glock_operations *glops, unsigned int state, int flags); void gfs2_glock_inode_squish(struct inode *inode); diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 75d4c50cff45cf..0c92c52fc92aee 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -493,13 +493,13 @@ static int quota_go_demote_ok(struct gfs2_glock *gl) return !atomic_read(&gl->gl_lvb_count); } -struct gfs2_glock_operations gfs2_meta_glops = { +const struct gfs2_glock_operations gfs2_meta_glops = { .go_xmote_th = gfs2_glock_xmote_th, .go_drop_th = gfs2_glock_drop_th, .go_type = LM_TYPE_META }; -struct gfs2_glock_operations gfs2_inode_glops = { +const struct gfs2_glock_operations gfs2_inode_glops = { .go_xmote_th = inode_go_xmote_th, .go_xmote_bh = inode_go_xmote_bh, .go_drop_th = inode_go_drop_th, @@ -512,7 +512,7 @@ struct gfs2_glock_operations gfs2_inode_glops = { .go_type = LM_TYPE_INODE }; -struct gfs2_glock_operations gfs2_rgrp_glops = { +const struct gfs2_glock_operations gfs2_rgrp_glops = { .go_xmote_th = gfs2_glock_xmote_th, .go_drop_th = gfs2_glock_drop_th, .go_sync = meta_go_sync, @@ -523,40 +523,40 @@ struct gfs2_glock_operations gfs2_rgrp_glops = { .go_type = LM_TYPE_RGRP }; -struct gfs2_glock_operations gfs2_trans_glops = { +const struct gfs2_glock_operations gfs2_trans_glops = { .go_xmote_th = trans_go_xmote_th, .go_xmote_bh = trans_go_xmote_bh, .go_drop_th = trans_go_drop_th, .go_type = LM_TYPE_NONDISK }; -struct gfs2_glock_operations gfs2_iopen_glops = { +const struct gfs2_glock_operations gfs2_iopen_glops = { .go_xmote_th = gfs2_glock_xmote_th, .go_drop_th = gfs2_glock_drop_th, .go_callback = gfs2_iopen_go_callback, .go_type = LM_TYPE_IOPEN }; -struct gfs2_glock_operations gfs2_flock_glops = { +const struct gfs2_glock_operations gfs2_flock_glops = { .go_xmote_th = gfs2_glock_xmote_th, .go_drop_th = gfs2_glock_drop_th, .go_type = LM_TYPE_FLOCK }; -struct gfs2_glock_operations gfs2_nondisk_glops = { +const struct gfs2_glock_operations gfs2_nondisk_glops = { .go_xmote_th = gfs2_glock_xmote_th, .go_drop_th = gfs2_glock_drop_th, .go_type = LM_TYPE_NONDISK }; -struct gfs2_glock_operations gfs2_quota_glops = { +const struct gfs2_glock_operations gfs2_quota_glops = { .go_xmote_th = gfs2_glock_xmote_th, .go_drop_th = gfs2_glock_drop_th, .go_demote_ok = quota_go_demote_ok, .go_type = LM_TYPE_QUOTA }; -struct gfs2_glock_operations gfs2_journal_glops = { +const struct gfs2_glock_operations gfs2_journal_glops = { .go_xmote_th = gfs2_glock_xmote_th, .go_drop_th = gfs2_glock_drop_th, .go_type = LM_TYPE_JOURNAL diff --git a/fs/gfs2/glops.h b/fs/gfs2/glops.h index 5c1e9491024f89..9409f0a7b47f55 100644 --- a/fs/gfs2/glops.h +++ b/fs/gfs2/glops.h @@ -10,14 +10,14 @@ #ifndef __GLOPS_DOT_H__ #define __GLOPS_DOT_H__ -extern struct gfs2_glock_operations gfs2_meta_glops; -extern struct gfs2_glock_operations gfs2_inode_glops; -extern struct gfs2_glock_operations gfs2_rgrp_glops; -extern struct gfs2_glock_operations gfs2_trans_glops; -extern struct gfs2_glock_operations gfs2_iopen_glops; -extern struct gfs2_glock_operations gfs2_flock_glops; -extern struct gfs2_glock_operations gfs2_nondisk_glops; -extern struct gfs2_glock_operations gfs2_quota_glops; -extern struct gfs2_glock_operations gfs2_journal_glops; +extern const struct gfs2_glock_operations gfs2_meta_glops; +extern const struct gfs2_glock_operations gfs2_inode_glops; +extern const struct gfs2_glock_operations gfs2_rgrp_glops; +extern const struct gfs2_glock_operations gfs2_trans_glops; +extern const struct gfs2_glock_operations gfs2_iopen_glops; +extern const struct gfs2_glock_operations gfs2_flock_glops; +extern const struct gfs2_glock_operations gfs2_nondisk_glops; +extern const struct gfs2_glock_operations gfs2_quota_glops; +extern const struct gfs2_glock_operations gfs2_journal_glops; #endif /* __GLOPS_DOT_H__ */ diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 77f0903d2f3ebb..38098ac292afc7 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -130,7 +130,7 @@ struct gfs2_glock_operations { void (*go_unlock) (struct gfs2_holder * gh); void (*go_callback) (struct gfs2_glock * gl, unsigned int state); void (*go_greedy) (struct gfs2_glock * gl); - int go_type; + const int go_type; }; enum { @@ -189,7 +189,7 @@ struct gfs2_glock { struct list_head gl_waiters2; /* HIF_DEMOTE, HIF_GREEDY */ struct list_head gl_waiters3; /* HIF_PROMOTE */ - struct gfs2_glock_operations *gl_ops; + const struct gfs2_glock_operations *gl_ops; struct gfs2_holder *gl_req_gh; gfs2_glop_bh_t gl_req_bh; -- cgit 1.2.3-korg From 5e2b0613ed9f9641937dd5948051631249447c57 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 30 Aug 2006 09:38:30 -0400 Subject: [GFS2] Remove unused code from glock layer Remove the unused sync feature from glocks. This is currently done by calling the required functions to sync pages/blocks directly so this code isn't needed. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 8 -------- fs/gfs2/glock.h | 1 - fs/gfs2/glops.c | 2 -- fs/gfs2/incore.h | 1 - 4 files changed, 12 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 709e6e0914fdca..c3dde8560827ec 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1296,9 +1296,6 @@ void gfs2_glock_dq(struct gfs2_holder *gh) struct gfs2_glock *gl = gh->gh_gl; const struct gfs2_glock_operations *glops = gl->gl_ops; - if (gh->gh_flags & GL_SYNC) - set_bit(GLF_SYNC, &gl->gl_flags); - if (gh->gh_flags & GL_NOCACHE) handle_callback(gl, LM_ST_UNLOCKED); @@ -1313,11 +1310,6 @@ void gfs2_glock_dq(struct gfs2_holder *gh) if (glops->go_unlock) glops->go_unlock(gh); - if (test_bit(GLF_SYNC, &gl->gl_flags)) { - if (glops->go_sync) - glops->go_sync(gl, DIO_METADATA | DIO_DATA); - } - gl->gl_stamp = jiffies; spin_lock(&gl->gl_spin); diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 12bdbfee4ddcbd..75fad634ced236 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -24,7 +24,6 @@ #define GL_SKIP 0x00000100 #define GL_ATIME 0x00000200 #define GL_NOCACHE 0x00000400 -#define GL_SYNC 0x00000800 #define GL_NOCANCEL 0x00001000 #define GL_AOP 0x00004000 #define GL_DUMP 0x00008000 diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 0c92c52fc92aee..1a30fa9bec7abc 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -137,7 +137,6 @@ static void meta_go_sync(struct gfs2_glock *gl, int flags) gfs2_ail_empty_gl(gl); } - clear_bit(GLF_SYNC, &gl->gl_flags); } /** @@ -236,7 +235,6 @@ static void inode_go_sync(struct gfs2_glock *gl, int flags) gfs2_ail_empty_gl(gl); } - clear_bit(GLF_SYNC, &gl->gl_flags); } /** diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 38098ac292afc7..362c2422d50696 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -167,7 +167,6 @@ enum { GLF_LOCK = 1, GLF_STICKY = 2, GLF_PREFETCH = 3, - GLF_SYNC = 4, GLF_DIRTY = 5, GLF_SKIP_WAITERS2 = 6, GLF_GREEDY = 7, -- cgit 1.2.3-korg From ec45d9f583b3663f90a7c5c559fd13e6e4c56ad5 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 30 Aug 2006 10:36:52 -0400 Subject: [GFS2] Use slab properly with glocks We can take advantage of the slab allocator to ensure that all the list heads and the spinlock (plus one or two other fields) are initialised by slab to speed up allocation of glocks. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 39 ++++++++++++--------------------------- fs/gfs2/main.c | 23 ++++++++++++++++++++++- 2 files changed, 34 insertions(+), 28 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index c3dde8560827ec..4a2e90dc1d02e7 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -278,31 +278,22 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, if (!gl) return -ENOMEM; - memset(gl, 0, sizeof(struct gfs2_glock)); - - INIT_LIST_HEAD(&gl->gl_list); + gl->gl_flags = 0; gl->gl_name = name; kref_init(&gl->gl_ref); - - spin_lock_init(&gl->gl_spin); - gl->gl_state = LM_ST_UNLOCKED; gl->gl_owner = NULL; gl->gl_ip = 0; - INIT_LIST_HEAD(&gl->gl_holders); - INIT_LIST_HEAD(&gl->gl_waiters1); - INIT_LIST_HEAD(&gl->gl_waiters2); - INIT_LIST_HEAD(&gl->gl_waiters3); - gl->gl_ops = glops; - + gl->gl_req_gh = NULL; + gl->gl_req_bh = NULL; + gl->gl_vn = 0; + gl->gl_stamp = jiffies; + gl->gl_object = NULL; gl->gl_bucket = bucket; - INIT_LIST_HEAD(&gl->gl_reclaim); - gl->gl_sbd = sdp; - + gl->gl_aspace = NULL; lops_init_le(&gl->gl_le, &gfs2_glock_lops); - INIT_LIST_HEAD(&gl->gl_ail_list); /* If this glock protects actual on-disk data or metadata blocks, create a VFS inode to manage the pages/buffers holding them. */ @@ -334,13 +325,11 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, return 0; - fail_aspace: +fail_aspace: if (gl->gl_aspace) gfs2_aspace_put(gl->gl_aspace); - - fail: +fail: kmem_cache_free(gfs2_glock_cachep, gl); - return error; } @@ -495,9 +484,7 @@ static int rq_promote(struct gfs2_holder *gh) gfs2_reclaim_glock(sdp); } - glops->go_xmote_th(gl, gh->gh_state, - gh->gh_flags); - + glops->go_xmote_th(gl, gh->gh_state, gh->gh_flags); spin_lock(&gl->gl_spin); } return 1; @@ -935,8 +922,7 @@ void gfs2_glock_xmote_th(struct gfs2_glock *gl, unsigned int state, int flags) gfs2_glock_hold(gl); gl->gl_req_bh = xmote_bh; - lck_ret = gfs2_lm_lock(sdp, gl->gl_lock, gl->gl_state, state, - lck_flags); + lck_ret = gfs2_lm_lock(sdp, gl->gl_lock, gl->gl_state, state, lck_flags); if (gfs2_assert_withdraw(sdp, !(lck_ret & LM_OUT_ERROR))) return; @@ -1019,8 +1005,7 @@ void gfs2_glock_drop_th(struct gfs2_glock *gl) if (gl->gl_state == LM_ST_EXCLUSIVE) { if (glops->go_sync) - glops->go_sync(gl, - DIO_METADATA | DIO_DATA | DIO_RELEASE); + glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE); } gfs2_glock_hold(gl); diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index c112943ee8c193..dccc4f6f503ff8 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "gfs2.h" #include "lm_interface.h" @@ -35,6 +36,25 @@ static void gfs2_init_inode_once(void *foo, kmem_cache_t *cachep, unsigned long } } +static void gfs2_init_glock_once(void *foo, kmem_cache_t *cachep, unsigned long flags) +{ + struct gfs2_glock *gl = foo; + if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == + SLAB_CTOR_CONSTRUCTOR) { + INIT_LIST_HEAD(&gl->gl_list); + spin_lock_init(&gl->gl_spin); + INIT_LIST_HEAD(&gl->gl_holders); + INIT_LIST_HEAD(&gl->gl_waiters1); + INIT_LIST_HEAD(&gl->gl_waiters2); + INIT_LIST_HEAD(&gl->gl_waiters3); + gl->gl_lvb = NULL; + atomic_set(&gl->gl_lvb_count, 0); + INIT_LIST_HEAD(&gl->gl_reclaim); + INIT_LIST_HEAD(&gl->gl_ail_list); + atomic_set(&gl->gl_ail_count, 0); + } +} + /** * init_gfs2_fs - Register GFS2 as a filesystem * @@ -55,7 +75,8 @@ static int __init init_gfs2_fs(void) gfs2_glock_cachep = kmem_cache_create("gfs2_glock", sizeof(struct gfs2_glock), - 0, 0, NULL, NULL); + 0, 0, + gfs2_init_glock_once, NULL); if (!gfs2_glock_cachep) goto fail; -- cgit 1.2.3-korg From d6a53727683bbf993c01ab49b45e0eac17e23df1 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 30 Aug 2006 11:16:23 -0400 Subject: [GFS2] Use const on glock lookup key Use const for the glock name which is being used as a lookup key in the glock hash table. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 4a2e90dc1d02e7..679cb836ed0cc1 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -83,7 +83,7 @@ static inline int relaxed_state_ok(unsigned int actual, unsigned requested, * Returns: The number of the corresponding hash bucket */ -static unsigned int gl_hash(struct lm_lockname *name) +static unsigned int gl_hash(const struct lm_lockname *name) { unsigned int h; @@ -200,7 +200,7 @@ static inline int queue_empty(struct gfs2_glock *gl, struct list_head *head) */ static struct gfs2_glock *search_bucket(struct gfs2_gl_hash_bucket *bucket, - struct lm_lockname *name) + const struct lm_lockname *name) { struct gfs2_glock *gl; @@ -227,7 +227,7 @@ static struct gfs2_glock *search_bucket(struct gfs2_gl_hash_bucket *bucket, */ static struct gfs2_glock *gfs2_glock_find(struct gfs2_sbd *sdp, - struct lm_lockname *name) + const struct lm_lockname *name) { struct gfs2_gl_hash_bucket *bucket = &sdp->sd_gl_hash[gl_hash(name)]; struct gfs2_glock *gl; -- cgit 1.2.3-korg From 899be4d3b7e00bf364d84c1c8cfe8bbbd1e3507b Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 30 Aug 2006 12:50:28 -0400 Subject: [GFS2] Add superblock into key for glock lookups This adds the superblock as a key for glock lookups. Since the glocks are already stored in a per-superblock table, this has no effect at the moment. Later on this will change though. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 679cb836ed0cc1..b8ccb27906e81c 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -200,6 +200,7 @@ static inline int queue_empty(struct gfs2_glock *gl, struct list_head *head) */ static struct gfs2_glock *search_bucket(struct gfs2_gl_hash_bucket *bucket, + const struct gfs2_sbd *sdp, const struct lm_lockname *name) { struct gfs2_glock *gl; @@ -209,6 +210,8 @@ static struct gfs2_glock *search_bucket(struct gfs2_gl_hash_bucket *bucket, continue; if (!lm_name_equal(&gl->gl_name, name)) continue; + if (gl->gl_sbd != sdp) + continue; kref_get(&gl->gl_ref); @@ -233,7 +236,7 @@ static struct gfs2_glock *gfs2_glock_find(struct gfs2_sbd *sdp, struct gfs2_glock *gl; read_lock(&bucket->hb_lock); - gl = search_bucket(bucket, name); + gl = search_bucket(bucket, sdp, name); read_unlock(&bucket->hb_lock); return gl; @@ -266,7 +269,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, bucket = &sdp->sd_gl_hash[gl_hash(&name)]; read_lock(&bucket->hb_lock); - gl = search_bucket(bucket, &name); + gl = search_bucket(bucket, sdp, &name); read_unlock(&bucket->hb_lock); if (gl || !create) { @@ -311,7 +314,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, goto fail_aspace; write_lock(&bucket->hb_lock); - tmp = search_bucket(bucket, &name); + tmp = search_bucket(bucket, sdp, &name); if (tmp) { write_unlock(&bucket->hb_lock); glock_free(gl); -- cgit 1.2.3-korg From e9fc2aa091ab8fa46e60d4c9d06a89305c441652 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Fri, 1 Sep 2006 11:05:15 -0400 Subject: [GFS2] Update copyright, tidy up incore.h As per comments from Jan Engelhardt this updates the copyright message to say "version" in full rather than "v.2". Also incore.h has been updated to remove forward structure declarations which are not required. The gfs2_quota_lvb structure has now had endianess annotations added to it. Also quota.c has been updated so that we now store the lvb data locally in endian independant format to avoid needing a structure in host endianess too. As a result the endianess conversions are done as required at various points and thus the conversion routines in lvb.[ch] are no longer required. I've moved the one remaining constant in lvb.h thats used into lm.h and removed the unused lvb.[ch]. I have not changed the HIF_ constants. That is left to a later patch which I hope will unify the gh_flags and gh_iflags fields of the struct gfs2_holder. Cc: Jan Engelhardt Signed-off-by: Steven Whitehouse --- fs/gfs2/Makefile | 2 +- fs/gfs2/acl.c | 2 +- fs/gfs2/acl.h | 2 +- fs/gfs2/bmap.c | 2 +- fs/gfs2/bmap.h | 2 +- fs/gfs2/daemon.c | 2 +- fs/gfs2/daemon.h | 2 +- fs/gfs2/dir.c | 2 +- fs/gfs2/dir.h | 2 +- fs/gfs2/eaops.c | 2 +- fs/gfs2/eaops.h | 2 +- fs/gfs2/eattr.c | 2 +- fs/gfs2/eattr.h | 2 +- fs/gfs2/format.h | 2 +- fs/gfs2/gfs2.h | 2 +- fs/gfs2/glock.c | 2 +- fs/gfs2/glock.h | 2 +- fs/gfs2/glops.c | 2 +- fs/gfs2/glops.h | 2 +- fs/gfs2/incore.h | 28 +++++++--------------- fs/gfs2/inode.c | 2 +- fs/gfs2/inode.h | 2 +- fs/gfs2/lm.c | 3 +-- fs/gfs2/lm.h | 4 +++- fs/gfs2/lm_interface.h | 2 +- fs/gfs2/locking.c | 2 +- fs/gfs2/locking/dlm/lock.c | 2 +- fs/gfs2/locking/dlm/lock_dlm.h | 2 +- fs/gfs2/locking/dlm/main.c | 2 +- fs/gfs2/locking/dlm/mount.c | 2 +- fs/gfs2/locking/dlm/plock.c | 2 +- fs/gfs2/locking/dlm/sysfs.c | 2 +- fs/gfs2/locking/dlm/thread.c | 2 +- fs/gfs2/locking/nolock/main.c | 2 +- fs/gfs2/log.c | 2 +- fs/gfs2/log.h | 2 +- fs/gfs2/lops.c | 2 +- fs/gfs2/lops.h | 2 +- fs/gfs2/lvb.c | 45 ----------------------------------- fs/gfs2/lvb.h | 19 --------------- fs/gfs2/main.c | 2 +- fs/gfs2/meta_io.c | 2 +- fs/gfs2/meta_io.h | 2 +- fs/gfs2/mount.c | 2 +- fs/gfs2/mount.h | 2 +- fs/gfs2/ondisk.c | 2 +- fs/gfs2/ops_address.c | 2 +- fs/gfs2/ops_address.h | 2 +- fs/gfs2/ops_dentry.c | 2 +- fs/gfs2/ops_dentry.h | 2 +- fs/gfs2/ops_export.c | 2 +- fs/gfs2/ops_export.h | 2 +- fs/gfs2/ops_file.c | 2 +- fs/gfs2/ops_file.h | 2 +- fs/gfs2/ops_fstype.c | 2 +- fs/gfs2/ops_fstype.h | 2 +- fs/gfs2/ops_inode.c | 2 +- fs/gfs2/ops_inode.h | 2 +- fs/gfs2/ops_super.c | 2 +- fs/gfs2/ops_super.h | 2 +- fs/gfs2/ops_vm.c | 2 +- fs/gfs2/ops_vm.h | 2 +- fs/gfs2/quota.c | 54 +++++++++++++++++++++--------------------- fs/gfs2/quota.h | 2 +- fs/gfs2/recovery.c | 2 +- fs/gfs2/recovery.h | 2 +- fs/gfs2/rgrp.c | 2 +- fs/gfs2/rgrp.h | 2 +- fs/gfs2/super.c | 2 +- fs/gfs2/super.h | 2 +- fs/gfs2/sys.c | 2 +- fs/gfs2/sys.h | 2 +- fs/gfs2/trans.c | 2 +- fs/gfs2/trans.h | 2 +- fs/gfs2/util.c | 2 +- fs/gfs2/util.h | 2 +- 76 files changed, 109 insertions(+), 184 deletions(-) delete mode 100644 fs/gfs2/lvb.c delete mode 100644 fs/gfs2/lvb.h (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/Makefile b/fs/gfs2/Makefile index b92852b6662933..e3f1ada643ac11 100644 --- a/fs/gfs2/Makefile +++ b/fs/gfs2/Makefile @@ -1,6 +1,6 @@ obj-$(CONFIG_GFS2_FS) += gfs2.o gfs2-y := acl.o bmap.o daemon.o dir.o eaops.o eattr.o glock.o \ - glops.o inode.o lm.o log.o lops.o locking.o lvb.o main.o meta_io.o \ + glops.o inode.o lm.o log.o lops.o locking.o main.o meta_io.o \ mount.o ondisk.o ops_address.o ops_dentry.o ops_export.o ops_file.o \ ops_fstype.o ops_inode.o ops_super.o ops_vm.o quota.o \ recovery.o rgrp.o super.o sys.o trans.o util.o diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index 399317841501eb..60c98c0314a180 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/acl.h b/fs/gfs2/acl.h index 067105786eaa82..5856ba764680db 100644 --- a/fs/gfs2/acl.h +++ b/fs/gfs2/acl.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __ACL_DOT_H__ diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index d20d41e1c0285b..913c0e5490e990 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/bmap.h b/fs/gfs2/bmap.h index 1a265412f7eef7..ab0157c5ed0e5a 100644 --- a/fs/gfs2/bmap.h +++ b/fs/gfs2/bmap.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __BMAP_DOT_H__ diff --git a/fs/gfs2/daemon.c b/fs/gfs2/daemon.c index 1453605c8f32d8..a2a07c41845d41 100644 --- a/fs/gfs2/daemon.c +++ b/fs/gfs2/daemon.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/daemon.h b/fs/gfs2/daemon.h index aa93eb6f668e33..801007120fb266 100644 --- a/fs/gfs2/daemon.h +++ b/fs/gfs2/daemon.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __DAEMON_DOT_H__ diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 76a23c172eebd6..7b8a38eaa41a08 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ /* diff --git a/fs/gfs2/dir.h b/fs/gfs2/dir.h index 173403095eb221..366a5571648f61 100644 --- a/fs/gfs2/dir.h +++ b/fs/gfs2/dir.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __DIR_DOT_H__ diff --git a/fs/gfs2/eaops.c b/fs/gfs2/eaops.c index 3ace242f2b1684..3b8749c22731db 100644 --- a/fs/gfs2/eaops.c +++ b/fs/gfs2/eaops.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/eaops.h b/fs/gfs2/eaops.h index 3dece17e31166d..1c27700ee8b868 100644 --- a/fs/gfs2/eaops.h +++ b/fs/gfs2/eaops.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __EAOPS_DOT_H__ diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c index 96736932260f2e..9081822ce80cbe 100644 --- a/fs/gfs2/eattr.c +++ b/fs/gfs2/eattr.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/eattr.h b/fs/gfs2/eattr.h index ae199692e51db9..7b0291f99fd9fa 100644 --- a/fs/gfs2/eattr.h +++ b/fs/gfs2/eattr.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __EATTR_DOT_H__ diff --git a/fs/gfs2/format.h b/fs/gfs2/format.h index 239f0c3553fc47..9acbf457ee58f5 100644 --- a/fs/gfs2/format.h +++ b/fs/gfs2/format.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __FORMAT_DOT_H__ diff --git a/fs/gfs2/gfs2.h b/fs/gfs2/gfs2.h index 6edbd551a4c041..3bb11c0f8b56a1 100644 --- a/fs/gfs2/gfs2.h +++ b/fs/gfs2/gfs2.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __GFS2_DOT_H__ diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index b8ccb27906e81c..989f4f78f9be74 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 75fad634ced236..07a8d02a234d20 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __GLOCK_DOT_H__ diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 1a30fa9bec7abc..8e1d8ee68e2ec2 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/glops.h b/fs/gfs2/glops.h index 9409f0a7b47f55..ba943e4736658b 100644 --- a/fs/gfs2/glops.h +++ b/fs/gfs2/glops.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __GLOPS_DOT_H__ diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 362c2422d50696..06f5ec6ebf7faf 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __INCORE_DOT_H__ @@ -22,24 +22,12 @@ struct gfs2_log_operations; struct gfs2_log_element; -struct gfs2_bitmap; -struct gfs2_rgrpd; -struct gfs2_bufdata; -struct gfs2_glock_operations; struct gfs2_holder; struct gfs2_glock; -struct gfs2_alloc; -struct gfs2_inode; -struct gfs2_file; -struct gfs2_revoke; -struct gfs2_revoke_replay; struct gfs2_quota_data; -struct gfs2_log_buf; struct gfs2_trans; struct gfs2_ail; struct gfs2_jdesc; -struct gfs2_args; -struct gfs2_tune; struct gfs2_gl_hash_bucket; struct gfs2_sbd; @@ -215,8 +203,8 @@ struct gfs2_glock { struct gfs2_alloc { /* Quota stuff */ - struct gfs2_quota_data *al_qd[4]; - struct gfs2_holder al_qd_ghs[4]; + struct gfs2_quota_data *al_qd[2*MAXQUOTAS]; + struct gfs2_holder al_qd_ghs[2*MAXQUOTAS]; unsigned int al_qd_num; u32 al_requested; /* Filled in by caller of gfs2_inplace_reserve() */ @@ -305,11 +293,11 @@ enum { }; struct gfs2_quota_lvb { - uint32_t qb_magic; - uint32_t __pad; - uint64_t qb_limit; /* Hard limit of # blocks to alloc */ - uint64_t qb_warn; /* Warn user when alloc is above this # */ - int64_t qb_value; /* Current # blocks allocated */ + __be32 qb_magic; + u32 __pad; + __be64 qb_limit; /* Hard limit of # blocks to alloc */ + __be64 qb_warn; /* Warn user when alloc is above this # */ + __be64 qb_value; /* Current # blocks allocated */ }; struct gfs2_quota_data { diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 9fb340984b2945..decb0cf8569122 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h index 8bb8b559bceab7..32015d89f24999 100644 --- a/fs/gfs2/inode.h +++ b/fs/gfs2/inode.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __INODE_DOT_H__ diff --git a/fs/gfs2/lm.c b/fs/gfs2/lm.c index f45c0ffd1c3564..1a9e75da19d1ce 100644 --- a/fs/gfs2/lm.c +++ b/fs/gfs2/lm.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include @@ -22,7 +22,6 @@ #include "lm.h" #include "super.h" #include "util.h" -#include "lvb.h" /** * gfs2_lm_mount - mount a locking protocol diff --git a/fs/gfs2/lm.h b/fs/gfs2/lm.h index e821101d19c0a3..15839aaa4ca6f3 100644 --- a/fs/gfs2/lm.h +++ b/fs/gfs2/lm.h @@ -4,12 +4,14 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __LM_DOT_H__ #define __LM_DOT_H__ +#define GFS2_MIN_LVB_SIZE 32 + int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent); void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp); void gfs2_lm_unmount(struct gfs2_sbd *sdp); diff --git a/fs/gfs2/lm_interface.h b/fs/gfs2/lm_interface.h index 1da95a55f768f3..e1e89d92a8dbb5 100644 --- a/fs/gfs2/lm_interface.h +++ b/fs/gfs2/lm_interface.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __LM_INTERFACE_DOT_H__ diff --git a/fs/gfs2/locking.c b/fs/gfs2/locking.c index ded1ef6c81e7c6..11c4068105ccb7 100644 --- a/fs/gfs2/locking.c +++ b/fs/gfs2/locking.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/locking/dlm/lock.c b/fs/gfs2/locking/dlm/lock.c index f769eac1a34ac7..2d81d90db0970d 100644 --- a/fs/gfs2/locking/dlm/lock.c +++ b/fs/gfs2/locking/dlm/lock.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include "lock_dlm.h" diff --git a/fs/gfs2/locking/dlm/lock_dlm.h b/fs/gfs2/locking/dlm/lock_dlm.h index 530c2f542584da..941063498532ba 100644 --- a/fs/gfs2/locking/dlm/lock_dlm.h +++ b/fs/gfs2/locking/dlm/lock_dlm.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef LOCK_DLM_DOT_H diff --git a/fs/gfs2/locking/dlm/main.c b/fs/gfs2/locking/dlm/main.c index 870a1cd99f5781..2194b1d5b5ec71 100644 --- a/fs/gfs2/locking/dlm/main.c +++ b/fs/gfs2/locking/dlm/main.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/locking/dlm/mount.c b/fs/gfs2/locking/dlm/mount.c index 3caeafc02a1b6d..f279385774b7ee 100644 --- a/fs/gfs2/locking/dlm/mount.c +++ b/fs/gfs2/locking/dlm/mount.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include "lock_dlm.h" diff --git a/fs/gfs2/locking/dlm/plock.c b/fs/gfs2/locking/dlm/plock.c index 1acb2519f4391d..263636b390febf 100644 --- a/fs/gfs2/locking/dlm/plock.c +++ b/fs/gfs2/locking/dlm/plock.c @@ -3,7 +3,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/locking/dlm/sysfs.c b/fs/gfs2/locking/dlm/sysfs.c index 0d8bd0806dba9e..82bef017f944c6 100644 --- a/fs/gfs2/locking/dlm/sysfs.c +++ b/fs/gfs2/locking/dlm/sysfs.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/locking/dlm/thread.c b/fs/gfs2/locking/dlm/thread.c index 489235b2edba17..0b4be102e1705d 100644 --- a/fs/gfs2/locking/dlm/thread.c +++ b/fs/gfs2/locking/dlm/thread.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include "lock_dlm.h" diff --git a/fs/gfs2/locking/nolock/main.c b/fs/gfs2/locking/nolock/main.c index 748aa5d3364151..95a29914730aec 100644 --- a/fs/gfs2/locking/nolock/main.c +++ b/fs/gfs2/locking/nolock/main.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index af728cb3b3278e..45ea3ec6f776e3 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h index 8cfd0f1d29f835..80764e388bb2cb 100644 --- a/fs/gfs2/log.h +++ b/fs/gfs2/log.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __LOG_DOT_H__ diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 0ec38b3990977b..e2c2582c8f6e04 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/lops.h b/fs/gfs2/lops.h index 8a1029d3d389a3..2e3365c2b1019f 100644 --- a/fs/gfs2/lops.h +++ b/fs/gfs2/lops.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __LOPS_DOT_H__ diff --git a/fs/gfs2/lvb.c b/fs/gfs2/lvb.c deleted file mode 100644 index e88e9cce14e76d..00000000000000 --- a/fs/gfs2/lvb.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. - * - * This copyrighted material is made available to anyone wishing to use, - * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. - */ - -#include -#include -#include -#include -#include -#include - -#include "gfs2.h" -#include "lm_interface.h" -#include "incore.h" -#include "lvb.h" - -#define pv(struct, member, fmt) printk(KERN_INFO " "#member" = "fmt"\n", \ - struct->member); - -void gfs2_quota_lvb_in(struct gfs2_quota_lvb *qb, char *lvb) -{ - struct gfs2_quota_lvb *str = (struct gfs2_quota_lvb *)lvb; - - qb->qb_magic = be32_to_cpu(str->qb_magic); - qb->qb_limit = be64_to_cpu(str->qb_limit); - qb->qb_warn = be64_to_cpu(str->qb_warn); - qb->qb_value = be64_to_cpu(str->qb_value); -} - -void gfs2_quota_lvb_out(struct gfs2_quota_lvb *qb, char *lvb) -{ - struct gfs2_quota_lvb *str = (struct gfs2_quota_lvb *)lvb; - - str->qb_magic = cpu_to_be32(qb->qb_magic); - str->qb_limit = cpu_to_be64(qb->qb_limit); - str->qb_warn = cpu_to_be64(qb->qb_warn); - str->qb_value = cpu_to_be64(qb->qb_value); -} - - diff --git a/fs/gfs2/lvb.h b/fs/gfs2/lvb.h deleted file mode 100644 index 1b1a8b75219a4c..00000000000000 --- a/fs/gfs2/lvb.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. - * - * This copyrighted material is made available to anyone wishing to use, - * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. - */ - -#ifndef __LVB_DOT_H__ -#define __LVB_DOT_H__ - -#define GFS2_MIN_LVB_SIZE 32 - -void gfs2_quota_lvb_in(struct gfs2_quota_lvb *qb, char *lvb); -void gfs2_quota_lvb_out(struct gfs2_quota_lvb *qb, char *lvb); - -#endif /* __LVB_DOT_H__ */ - diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index dccc4f6f503ff8..b46f400705a2be 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 502864b241963e..03850b64c072cf 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/meta_io.h b/fs/gfs2/meta_io.h index 951814e8627255..4ddc936aae16d1 100644 --- a/fs/gfs2/meta_io.h +++ b/fs/gfs2/meta_io.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __DIO_DOT_H__ diff --git a/fs/gfs2/mount.c b/fs/gfs2/mount.c index 0d4b230785af78..b66027827aaa26 100644 --- a/fs/gfs2/mount.c +++ b/fs/gfs2/mount.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/mount.h b/fs/gfs2/mount.h index 2eb14722144f04..8a21897b63e58c 100644 --- a/fs/gfs2/mount.h +++ b/fs/gfs2/mount.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __MOUNT_DOT_H__ diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c index 39c7f0345fc6cd..03881f9870f733 100644 --- a/fs/gfs2/ondisk.c +++ b/fs/gfs2/ondisk.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 0de7a952363385..21ae9e4f0f6c00 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/ops_address.h b/fs/gfs2/ops_address.h index dfc3dda6de1111..6c07aa2bd98a72 100644 --- a/fs/gfs2/ops_address.h +++ b/fs/gfs2/ops_address.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __OPS_ADDRESS_DOT_H__ diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c index fd55979ec42810..a1ba1ec8eef45d 100644 --- a/fs/gfs2/ops_dentry.c +++ b/fs/gfs2/ops_dentry.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/ops_dentry.h b/fs/gfs2/ops_dentry.h index 1b6e75c0a4a725..e7b05e5c62ec51 100644 --- a/fs/gfs2/ops_dentry.h +++ b/fs/gfs2/ops_dentry.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __OPS_DENTRY_DOT_H__ diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index 6354f4799e680a..c94cbc8b6ef60a 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/ops_export.h b/fs/gfs2/ops_export.h index 09fc077657d170..d52c2d93010c6f 100644 --- a/fs/gfs2/ops_export.h +++ b/fs/gfs2/ops_export.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __OPS_EXPORT_DOT_H__ diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index 145a29fa4ea48a..07a0c861ac4127 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/ops_file.h b/fs/gfs2/ops_file.h index 46302b51393773..064e52c306654b 100644 --- a/fs/gfs2/ops_file.h +++ b/fs/gfs2/ops_file.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __OPS_FILE_DOT_H__ diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index e5a91ead250cac..46f910e29bf082 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/ops_fstype.h b/fs/gfs2/ops_fstype.h index 622f5760d6b289..b85ecce3ca6bea 100644 --- a/fs/gfs2/ops_fstype.h +++ b/fs/gfs2/ops_fstype.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __OPS_FSTYPE_DOT_H__ diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 8fb7c5c9a7c3ee..1786a485acc54c 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/ops_inode.h b/fs/gfs2/ops_inode.h index 930aaae913771a..6f4b54783d29bd 100644 --- a/fs/gfs2/ops_inode.h +++ b/fs/gfs2/ops_inode.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __OPS_INODE_DOT_H__ diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 18ed18c729e81e..6ced71240379d2 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/ops_super.h b/fs/gfs2/ops_super.h index a15ccc27611317..cbc4f73e9a926b 100644 --- a/fs/gfs2/ops_super.h +++ b/fs/gfs2/ops_super.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __OPS_SUPER_DOT_H__ diff --git a/fs/gfs2/ops_vm.c b/fs/gfs2/ops_vm.c index 875a769444a1b6..451f48d62e588b 100644 --- a/fs/gfs2/ops_vm.c +++ b/fs/gfs2/ops_vm.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/ops_vm.h b/fs/gfs2/ops_vm.h index 077cffcd4085c5..d5ba4b9c50fdf4 100644 --- a/fs/gfs2/ops_vm.h +++ b/fs/gfs2/ops_vm.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __OPS_VM_DOT_H__ diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 3ca65c37c3547a..be87983a20a9f3 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ /* @@ -52,7 +52,6 @@ #include "glock.h" #include "glops.h" #include "log.h" -#include "lvb.h" #include "meta_io.h" #include "quota.h" #include "rgrp.h" @@ -586,7 +585,7 @@ static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc, struct page *page; void *kaddr; __be64 *ptr; - u64 value; + s64 value; int err = -EIO; page = grab_cache_page(mapping, index); @@ -627,7 +626,8 @@ static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc, kaddr = kmap_atomic(page, KM_USER0); ptr = (__be64 *)(kaddr + offset); - value = *ptr = cpu_to_be64(be64_to_cpu(*ptr) + change); + value = (s64)be64_to_cpu(*ptr) + change; + *ptr = cpu_to_be64(value); flush_dcache_page(page); kunmap_atomic(kaddr, KM_USER0); err = 0; @@ -761,6 +761,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, char buf[sizeof(struct gfs2_quota)]; struct file_ra_state ra_state; int error; + struct gfs2_quota_lvb *qlvb; file_ra_state_init(&ra_state, sdp->sd_quota_inode->i_mapping); restart: @@ -768,9 +769,9 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, if (error) return error; - gfs2_quota_lvb_in(&qd->qd_qb, qd->qd_gl->gl_lvb); + qd->qd_qb = *(struct gfs2_quota_lvb *)qd->qd_gl->gl_lvb; - if (force_refresh || qd->qd_qb.qb_magic != GFS2_MAGIC) { + if (force_refresh || qd->qd_qb.qb_magic != cpu_to_be32(GFS2_MAGIC)) { loff_t pos; gfs2_glock_dq_uninit(q_gh); error = gfs2_glock_nq_init(qd->qd_gl, @@ -779,9 +780,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, if (error) return error; - error = gfs2_glock_nq_init(ip->i_gl, - LM_ST_SHARED, 0, - &i_gh); + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh); if (error) goto fail; @@ -794,15 +793,15 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, gfs2_glock_dq_uninit(&i_gh); + gfs2_quota_in(&q, buf); - - memset(&qd->qd_qb, 0, sizeof(struct gfs2_quota_lvb)); - qd->qd_qb.qb_magic = GFS2_MAGIC; - qd->qd_qb.qb_limit = q.qu_limit; - qd->qd_qb.qb_warn = q.qu_warn; - qd->qd_qb.qb_value = q.qu_value; - - gfs2_quota_lvb_out(&qd->qd_qb, qd->qd_gl->gl_lvb); + qlvb = (struct gfs2_quota_lvb *)qd->qd_gl->gl_lvb; + qlvb->qb_magic = cpu_to_be32(GFS2_MAGIC); + qlvb->__pad = 0; + qlvb->qb_limit = cpu_to_be64(q.qu_limit); + qlvb->qb_warn = cpu_to_be64(q.qu_warn); + qlvb->qb_value = cpu_to_be64(q.qu_value); + qd->qd_qb = *qlvb; if (gfs2_glock_is_blocking(qd->qd_gl)) { gfs2_glock_dq_uninit(q_gh); @@ -877,13 +876,14 @@ static int need_sync(struct gfs2_quota_data *qd) if (value < 0) do_sync = 0; - else if (qd->qd_qb.qb_value >= (int64_t)qd->qd_qb.qb_limit) + else if ((s64)be64_to_cpu(qd->qd_qb.qb_value) >= + (s64)be64_to_cpu(qd->qd_qb.qb_limit)) do_sync = 0; else { value *= gfs2_jindex_size(sdp) * num; do_div(value, den); - value += qd->qd_qb.qb_value; - if (value < (int64_t)qd->qd_qb.qb_limit) + value += (s64)be64_to_cpu(qd->qd_qb.qb_value); + if (value < (int64_t)be64_to_cpu(qd->qd_qb.qb_limit)) do_sync = 0; } @@ -959,17 +959,17 @@ int gfs2_quota_check(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags)))) continue; - value = qd->qd_qb.qb_value; + value = (s64)be64_to_cpu(qd->qd_qb.qb_value); spin_lock(&sdp->sd_quota_spin); value += qd->qd_change; spin_unlock(&sdp->sd_quota_spin); - if (qd->qd_qb.qb_limit && (int64_t)qd->qd_qb.qb_limit < value) { + if (be64_to_cpu(qd->qd_qb.qb_limit) && (int64_t)be64_to_cpu(qd->qd_qb.qb_limit) < value) { print_message(qd, "exceeded"); error = -EDQUOT; break; - } else if (qd->qd_qb.qb_warn && - (int64_t)qd->qd_qb.qb_warn < value && + } else if (be64_to_cpu(qd->qd_qb.qb_warn) && + (int64_t)be64_to_cpu(qd->qd_qb.qb_warn) < value && time_after_eq(jiffies, qd->qd_last_warn + gfs2_tune_get(sdp, gt_quota_warn_period) * HZ)) { @@ -1088,9 +1088,9 @@ int gfs2_quota_read(struct gfs2_sbd *sdp, int user, uint32_t id, goto out; memset(q, 0, sizeof(struct gfs2_quota)); - q->qu_limit = qd->qd_qb.qb_limit; - q->qu_warn = qd->qd_qb.qb_warn; - q->qu_value = qd->qd_qb.qb_value; + q->qu_limit = be64_to_cpu(qd->qd_qb.qb_limit); + q->qu_warn = be64_to_cpu(qd->qd_qb.qb_warn); + q->qu_value = be64_to_cpu(qd->qd_qb.qb_value); spin_lock(&sdp->sd_quota_spin); q->qu_value += qd->qd_change; diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h index af05492f96447d..6702a56d49b539 100644 --- a/fs/gfs2/quota.h +++ b/fs/gfs2/quota.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __QUOTA_DOT_H__ diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index 8fe518cfb3de0c..acafe4b4d6f064 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/recovery.h b/fs/gfs2/recovery.h index ac0f1d6ce45647..bed1a7857f6e47 100644 --- a/fs/gfs2/recovery.h +++ b/fs/gfs2/recovery.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __RECOVERY_DOT_H__ diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 84fcc1bfaf1bcf..62d0a84df98272 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h index 14600944d1843a..f94761bf34605c 100644 --- a/fs/gfs2/rgrp.h +++ b/fs/gfs2/rgrp.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __RGRP_DOT_H__ diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 3c318a9e8a8c6d..2cf2802fc92e13 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/super.h b/fs/gfs2/super.h index df2495230402e6..4a6ce9582743be 100644 --- a/fs/gfs2/super.h +++ b/fs/gfs2/super.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __SUPER_DOT_H__ diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index 3c4cb455890573..3ffa88506c447a 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/sys.h b/fs/gfs2/sys.h index c46a700e801e7d..f8c01b50bfba3f 100644 --- a/fs/gfs2/sys.h +++ b/fs/gfs2/sys.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __SYS_DOT_H__ diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index 05e0b72d56ff09..8e18e634cbedcb 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/trans.h b/fs/gfs2/trans.h index fbef3f5a99e3e8..9e3ce84f6102f7 100644 --- a/fs/gfs2/trans.h +++ b/fs/gfs2/trans.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __TRANS_DOT_H__ diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c index 39e67b1ec70ab7..2852431764c915 100644 --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h index 8216d28bd816eb..60b370365eea6c 100644 --- a/fs/gfs2/util.h +++ b/fs/gfs2/util.h @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #ifndef __UTIL_DOT_H__ -- cgit 1.2.3-korg From 5029996547a9f3988459e11955c13259495308ef Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Mon, 4 Sep 2006 09:49:55 -0400 Subject: [GFS2] Tidy up locking code As per Jan Engelhardt's second email, this removes some unused code, and fixes up indenting in various places. Cc: Jan Engelhardt Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 53 +++++++++++------------------------------- fs/gfs2/glock.h | 6 ++--- fs/gfs2/lm.c | 62 +++++++++++++++----------------------------------- fs/gfs2/lm.h | 25 +++++++++----------- fs/gfs2/lm_interface.h | 2 -- fs/gfs2/locking.c | 10 ++------ fs/gfs2/main.c | 2 -- 7 files changed, 47 insertions(+), 113 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 989f4f78f9be74..fac271f390bfb7 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -300,8 +300,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, /* If this glock protects actual on-disk data or metadata blocks, create a VFS inode to manage the pages/buffers holding them. */ - if (glops == &gfs2_inode_glops || - glops == &gfs2_rgrp_glops) { + if (glops == &gfs2_inode_glops || glops == &gfs2_rgrp_glops) { gl->gl_aspace = gfs2_aspace_get(sdp); if (!gl->gl_aspace) { error = -ENOMEM; @@ -820,13 +819,11 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret) if (!gh) gl->gl_stamp = jiffies; - else if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) { spin_lock(&gl->gl_spin); list_del_init(&gh->gh_list); gh->gh_error = -EIO; spin_unlock(&gl->gl_spin); - } else if (test_bit(HIF_DEMOTE, &gh->gh_iflags)) { spin_lock(&gl->gl_spin); list_del_init(&gh->gh_list); @@ -842,7 +839,7 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret) spin_unlock(&gl->gl_spin); if (ret & LM_OUT_CANCELED) - handle_callback(gl, LM_ST_UNLOCKED); /* Lame */ + handle_callback(gl, LM_ST_UNLOCKED); } else if (ret & LM_OUT_CANCELED) { spin_lock(&gl->gl_spin); @@ -916,11 +913,8 @@ void gfs2_glock_xmote_th(struct gfs2_glock *gl, unsigned int state, int flags) gfs2_assert_warn(sdp, state != LM_ST_UNLOCKED); gfs2_assert_warn(sdp, state != gl->gl_state); - if (gl->gl_state == LM_ST_EXCLUSIVE) { - if (glops->go_sync) - glops->go_sync(gl, - DIO_METADATA | DIO_DATA | DIO_RELEASE); - } + if (gl->gl_state == LM_ST_EXCLUSIVE && glops->go_sync) + glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE); gfs2_glock_hold(gl); gl->gl_req_bh = xmote_bh; @@ -1006,10 +1000,8 @@ void gfs2_glock_drop_th(struct gfs2_glock *gl) gfs2_assert_warn(sdp, queue_empty(gl, &gl->gl_holders)); gfs2_assert_warn(sdp, gl->gl_state != LM_ST_UNLOCKED); - if (gl->gl_state == LM_ST_EXCLUSIVE) { - if (glops->go_sync) - glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE); - } + if (gl->gl_state == LM_ST_EXCLUSIVE && glops->go_sync) + glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE); gfs2_glock_hold(gl); gl->gl_req_bh = drop_bh; @@ -1041,9 +1033,8 @@ static void do_cancels(struct gfs2_holder *gh) while (gl->gl_req_gh != gh && !test_bit(HIF_HOLDER, &gh->gh_iflags) && !list_empty(&gh->gh_list)) { - if (gl->gl_req_bh && - !(gl->gl_req_gh && - (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) { + if (gl->gl_req_bh && !(gl->gl_req_gh && + (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) { spin_unlock(&gl->gl_spin); gfs2_lm_cancel(gl->gl_sbd, gl->gl_lock); msleep(100); @@ -1323,10 +1314,8 @@ static void gfs2_glock_prefetch(struct gfs2_glock *gl, unsigned int state, spin_lock(&gl->gl_spin); - if (test_bit(GLF_LOCK, &gl->gl_flags) || - !list_empty(&gl->gl_holders) || - !list_empty(&gl->gl_waiters1) || - !list_empty(&gl->gl_waiters2) || + if (test_bit(GLF_LOCK, &gl->gl_flags) || !list_empty(&gl->gl_holders) || + !list_empty(&gl->gl_waiters1) || !list_empty(&gl->gl_waiters2) || !list_empty(&gl->gl_waiters3) || relaxed_state_ok(gl->gl_state, state, flags)) { spin_unlock(&gl->gl_spin); @@ -1690,19 +1679,6 @@ void gfs2_lvb_unhold(struct gfs2_glock *gl) gfs2_glock_put(gl); } -#if 0 -void gfs2_lvb_sync(struct gfs2_glock *gl) -{ - gfs2_glmutex_lock(gl); - - gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count)); - if (!gfs2_assert_warn(gl->gl_sbd, gfs2_glock_is_held_excl(gl))) - gfs2_lm_sync_lvb(gl->gl_sbd, gl->gl_lock, gl->gl_lvb); - - gfs2_glmutex_unlock(gl); -} -#endif /* 0 */ - static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name, unsigned int state) { @@ -1813,8 +1789,7 @@ static int demote_ok(struct gfs2_glock *gl) if (test_bit(GLF_STICKY, &gl->gl_flags)) demote = 0; else if (test_bit(GLF_PREFETCH, &gl->gl_flags)) - demote = time_after_eq(jiffies, - gl->gl_stamp + + demote = time_after_eq(jiffies, gl->gl_stamp + gfs2_tune_get(sdp, gt_prefetch_secs) * HZ); else if (glops->go_demote_ok) demote = glops->go_demote_ok(gl); @@ -1872,8 +1847,7 @@ void gfs2_reclaim_glock(struct gfs2_sbd *sdp) if (gfs2_glmutex_trylock(gl)) { if (queue_empty(gl, &gl->gl_holders) && - gl->gl_state != LM_ST_UNLOCKED && - demote_ok(gl)) + gl->gl_state != LM_ST_UNLOCKED && demote_ok(gl)) handle_callback(gl, LM_ST_UNLOCKED); gfs2_glmutex_unlock(gl); } @@ -2036,8 +2010,7 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait) cont = 0; for (x = 0; x < GFS2_GL_HASH_SIZE; x++) - if (examine_bucket(clear_glock, sdp, - &sdp->sd_gl_hash[x])) + if (examine_bucket(clear_glock, sdp, &sdp->sd_gl_hash[x])) cont = 1; if (!wait || !cont) diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 07a8d02a234d20..1a90a1983bebec 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -51,17 +51,17 @@ static inline int gfs2_glock_is_locked_by_me(struct gfs2_glock *gl) static inline int gfs2_glock_is_held_excl(struct gfs2_glock *gl) { - return (gl->gl_state == LM_ST_EXCLUSIVE); + return gl->gl_state == LM_ST_EXCLUSIVE; } static inline int gfs2_glock_is_held_dfrd(struct gfs2_glock *gl) { - return (gl->gl_state == LM_ST_DEFERRED); + return gl->gl_state == LM_ST_DEFERRED; } static inline int gfs2_glock_is_held_shrd(struct gfs2_glock *gl) { - return (gl->gl_state == LM_ST_SHARED); + return gl->gl_state == LM_ST_SHARED; } static inline int gfs2_glock_is_blocking(struct gfs2_glock *gl) diff --git a/fs/gfs2/lm.c b/fs/gfs2/lm.c index 1a9e75da19d1ce..fb918c7de655d0 100644 --- a/fs/gfs2/lm.c +++ b/fs/gfs2/lm.c @@ -124,10 +124,8 @@ int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...) int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name, lm_lock_t **lockp) { - int error; - if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) - error = -EIO; - else + int error = -EIO; + if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) error = sdp->sd_lockstruct.ls_ops->lm_get_lock( sdp->sd_lockstruct.ls_lockspace, name, lockp); return error; @@ -143,12 +141,9 @@ unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, lm_lock_t *lock, unsigned int cur_state, unsigned int req_state, unsigned int flags) { - int ret; - if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) - ret = 0; - else - ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, - cur_state, + int ret = 0; + if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) + ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, cur_state, req_state, flags); return ret; } @@ -156,10 +151,8 @@ unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, lm_lock_t *lock, unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, lm_lock_t *lock, unsigned int cur_state) { - int ret; - if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) - ret = 0; - else + int ret = 0; + if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) ret = sdp->sd_lockstruct.ls_ops->lm_unlock(lock, cur_state); return ret; } @@ -172,10 +165,8 @@ void gfs2_lm_cancel(struct gfs2_sbd *sdp, lm_lock_t *lock) int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char **lvbp) { - int error; - if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) - error = -EIO; - else + int error = -EIO; + if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) error = sdp->sd_lockstruct.ls_ops->lm_hold_lvb(lock, lvbp); return error; } @@ -186,50 +177,33 @@ void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb) sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(lock, lvb); } -#if 0 -void gfs2_lm_sync_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb) -{ - if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) - sdp->sd_lockstruct.ls_ops->lm_sync_lvb(lock, lvb); -} -#endif /* 0 */ - int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name, struct file *file, struct file_lock *fl) { - int error; - if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) - error = -EIO; - else + int error = -EIO; + if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) error = sdp->sd_lockstruct.ls_ops->lm_plock_get( - sdp->sd_lockstruct.ls_lockspace, - name, file, fl); + sdp->sd_lockstruct.ls_lockspace, name, file, fl); return error; } int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name, struct file *file, int cmd, struct file_lock *fl) { - int error; - if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) - error = -EIO; - else + int error = -EIO; + if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) error = sdp->sd_lockstruct.ls_ops->lm_plock( - sdp->sd_lockstruct.ls_lockspace, - name, file, cmd, fl); + sdp->sd_lockstruct.ls_lockspace, name, file, cmd, fl); return error; } int gfs2_lm_punlock(struct gfs2_sbd *sdp, struct lm_lockname *name, struct file *file, struct file_lock *fl) { - int error; - if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) - error = -EIO; - else + int error = -EIO; + if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) error = sdp->sd_lockstruct.ls_ops->lm_punlock( - sdp->sd_lockstruct.ls_lockspace, - name, file, fl); + sdp->sd_lockstruct.ls_lockspace, name, file, fl); return error; } diff --git a/fs/gfs2/lm.h b/fs/gfs2/lm.h index 15839aaa4ca6f3..dbef88852ef300 100644 --- a/fs/gfs2/lm.h +++ b/fs/gfs2/lm.h @@ -16,9 +16,9 @@ int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent); void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp); void gfs2_lm_unmount(struct gfs2_sbd *sdp); int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...) -__attribute__ ((format(printf, 2, 3))); -int gfs2_lm_get_lock(struct gfs2_sbd *sdp, - struct lm_lockname *name, lm_lock_t **lockp); + __attribute__ ((format(printf, 2, 3))); +int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name, + lm_lock_t **lockp); void gfs2_lm_put_lock(struct gfs2_sbd *sdp, lm_lock_t *lock); unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, lm_lock_t *lock, unsigned int cur_state, unsigned int req_state, @@ -28,16 +28,13 @@ unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, lm_lock_t *lock, void gfs2_lm_cancel(struct gfs2_sbd *sdp, lm_lock_t *lock); int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char **lvbp); void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb); -int gfs2_lm_plock_get(struct gfs2_sbd *sdp, - struct lm_lockname *name, - struct file *file, struct file_lock *fl); -int gfs2_lm_plock(struct gfs2_sbd *sdp, - struct lm_lockname *name, - struct file *file, int cmd, struct file_lock *fl); -int gfs2_lm_punlock(struct gfs2_sbd *sdp, - struct lm_lockname *name, - struct file *file, struct file_lock *fl); -void gfs2_lm_recovery_done(struct gfs2_sbd *sdp, - unsigned int jid, unsigned int message); +int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name, + struct file *file, struct file_lock *fl); +int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name, + struct file *file, int cmd, struct file_lock *fl); +int gfs2_lm_punlock(struct gfs2_sbd *sdp, struct lm_lockname *name, + struct file *file, struct file_lock *fl); +void gfs2_lm_recovery_done(struct gfs2_sbd *sdp, unsigned int jid, + unsigned int message); #endif /* __LM_DOT_H__ */ diff --git a/fs/gfs2/lm_interface.h b/fs/gfs2/lm_interface.h index e1e89d92a8dbb5..0bf4c276e0fead 100644 --- a/fs/gfs2/lm_interface.h +++ b/fs/gfs2/lm_interface.h @@ -260,8 +260,6 @@ struct lm_lockstruct { int ls_flags; }; -void __init gfs2_init_lmh(void); - /* * Lock module bottom interface. A lock module makes itself available to GFS * with these functions. diff --git a/fs/gfs2/locking.c b/fs/gfs2/locking.c index 11c4068105ccb7..fce2001e5e256a 100644 --- a/fs/gfs2/locking.c +++ b/fs/gfs2/locking.c @@ -27,8 +27,8 @@ struct lmh_wrapper { /* List of registered low-level locking protocols. A file system selects one of them by name at mount time, e.g. lock_nolock, lock_dlm. */ -static struct list_head lmh_list; -static struct mutex lmh_lock; +static LIST_HEAD(lmh_list); +static DEFINE_MUTEX(lmh_lock); /** * gfs2_register_lockproto - Register a low-level locking protocol @@ -180,12 +180,6 @@ void gfs2_withdraw_lockproto(struct lm_lockstruct *lockstruct) mutex_unlock(&lmh_lock); } -void __init gfs2_init_lmh(void) -{ - mutex_init(&lmh_lock); - INIT_LIST_HEAD(&lmh_list); -} - EXPORT_SYMBOL_GPL(gfs2_register_lockproto); EXPORT_SYMBOL_GPL(gfs2_unregister_lockproto); diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index b46f400705a2be..143fda727a9cb7 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c @@ -65,8 +65,6 @@ static int __init init_gfs2_fs(void) { int error; - gfs2_init_lmh(); - error = gfs2_sys_init(); if (error) return error; -- cgit 1.2.3-korg From a91ea69ffd3f8a0b7139bfd44042ab384461e631 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Mon, 4 Sep 2006 12:04:26 -0400 Subject: [GFS2] Align all labels against LH side This makes everything consistent. Signed-off-by: Steven Whitehouse --- fs/gfs2/acl.c | 14 +++------ fs/gfs2/bmap.c | 39 ++++++++--------------- fs/gfs2/dir.c | 18 ++++------- fs/gfs2/eattr.c | 62 +++++++++++++------------------------ fs/gfs2/glock.c | 3 +- fs/gfs2/lm.c | 2 +- fs/gfs2/locking/dlm/lock.c | 2 +- fs/gfs2/locking/dlm/mount.c | 10 +++--- fs/gfs2/locking/dlm/thread.c | 2 +- fs/gfs2/meta_io.c | 2 +- fs/gfs2/mount.c | 4 +-- fs/gfs2/ops_dentry.c | 16 ++++------ fs/gfs2/ops_file.c | 3 +- fs/gfs2/ops_fstype.c | 73 +++++++++++++------------------------------- fs/gfs2/ops_inode.c | 26 ++++------------ fs/gfs2/ops_vm.c | 12 +++----- fs/gfs2/quota.c | 49 ++++++++++++----------------- fs/gfs2/super.c | 27 ++++++---------- fs/gfs2/sys.c | 10 +++--- 19 files changed, 129 insertions(+), 245 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index 60c98c0314a180..d846b5ad1d87f4 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c @@ -65,9 +65,8 @@ int gfs2_acl_validate_set(struct gfs2_inode *ip, int access, error = 0; } - out: +out: posix_acl_release(acl); - return error; } @@ -132,18 +131,16 @@ static int acl_get(struct gfs2_inode *ip, int access, struct posix_acl **acl, error = PTR_ERR(*acl); } - out_kfree: +out_kfree: if (error || !data) kfree(er.er_data); else { *data = er.er_data; *len = er.er_data_len; } - - out: +out: if (error || el == &el_this) brelse(el->el_bh); - return error; } @@ -270,7 +267,7 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip) } else munge_mode(ip, mode); - out: +out: posix_acl_release(acl); kfree(er.er_data); return error; @@ -303,11 +300,10 @@ int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr) error = gfs2_ea_acl_chmod(ip, &el, attr, data); } - out: +out: posix_acl_release(acl); brelse(el.el_bh); kfree(data); - return error; } diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index b75a2f93dadab0..bb597839c0c9b8 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -170,12 +170,10 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) gfs2_dinode_out(&ip->i_di, dibh->b_data); - out_brelse: +out_brelse: brelse(dibh); - - out: +out: up_write(&ip->i_rw_mutex); - return error; } @@ -642,9 +640,8 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh, break; } - out: +out: brelse(bh); - return error; } @@ -788,15 +785,12 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, gfs2_trans_end(sdp); - out_rg_gunlock: +out_rg_gunlock: gfs2_glock_dq_m(rlist.rl_rgrps, rlist.rl_ghs); - - out_rlist: +out_rlist: gfs2_rlist_free(&rlist); - - out: +out: gfs2_glock_dq_uninit(&ip->i_alloc.al_ri_gh); - return error; } @@ -868,18 +862,14 @@ static int do_grow(struct gfs2_inode *ip, uint64_t size) gfs2_dinode_out(&ip->i_di, dibh->b_data); brelse(dibh); - out_end_trans: +out_end_trans: gfs2_trans_end(sdp); - - out_ipres: +out_ipres: gfs2_inplace_release(ip); - - out_gunlock_q: +out_gunlock_q: gfs2_quota_unlock(ip); - - out: +out: gfs2_alloc_put(ip); - return error; } @@ -998,9 +988,8 @@ static int trunc_start(struct gfs2_inode *ip, uint64_t size) brelse(dibh); - out: +out: gfs2_trans_end(sdp); - return error; } @@ -1035,7 +1024,7 @@ static int trunc_dealloc(struct gfs2_inode *ip, uint64_t size) gfs2_quota_unhold(ip); - out: +out: gfs2_alloc_put(ip); return error; } @@ -1070,11 +1059,9 @@ static int trunc_end(struct gfs2_inode *ip) gfs2_dinode_out(&ip->i_di, dibh->b_data); brelse(dibh); - out: +out: up_write(&ip->i_rw_mutex); - gfs2_trans_end(sdp); - return error; } diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 7b8a38eaa41a08..59d0cbcaecffc1 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -1134,9 +1134,8 @@ static int dir_double_exhash(struct gfs2_inode *dip) return error; - fail: +fail: kfree(buf); - return error; } @@ -1890,23 +1889,18 @@ static int leaf_dealloc(struct gfs2_inode *dip, uint32_t index, uint32_t len, gfs2_dinode_out(&dip->i_di, dibh->b_data); brelse(dibh); - out_end_trans: +out_end_trans: gfs2_trans_end(sdp); - - out_rg_gunlock: +out_rg_gunlock: gfs2_glock_dq_m(rlist.rl_rgrps, rlist.rl_ghs); - - out_rlist: +out_rlist: gfs2_rlist_free(&rlist); gfs2_glock_dq_uninit(&dip->i_alloc.al_ri_gh); - - out_qs: +out_qs: gfs2_quota_unhold(dip); - - out: +out: gfs2_alloc_put(dip); kfree(ht); - return error; } diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c index 9081822ce80cbe..5a56e6568622b0 100644 --- a/fs/gfs2/eattr.c +++ b/fs/gfs2/eattr.c @@ -107,7 +107,7 @@ static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh, return error; - fail: +fail: gfs2_consist_inode(ip); return -EIO; } @@ -152,9 +152,8 @@ static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data) if (error) break; } - out: +out: brelse(bh); - return error; } @@ -319,9 +318,8 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, gfs2_trans_end(sdp); - out_gunlock: +out_gunlock: gfs2_glock_dq_uninit(&rg_gh); - return error; } @@ -348,12 +346,10 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, gfs2_glock_dq_uninit(&al->al_ri_gh); - out_quota: +out_quota: gfs2_quota_unhold(ip); - - out_alloc: +out_alloc: gfs2_alloc_put(ip); - return error; } @@ -506,9 +502,8 @@ static int ea_get_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea, brelse(bh[x]); } - out: +out: kfree(bh); - return error; } @@ -747,18 +742,14 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er, brelse(dibh); } - out_end_trans: +out_end_trans: gfs2_trans_end(GFS2_SB(&ip->i_inode)); - - out_ipres: +out_ipres: gfs2_inplace_release(ip); - - out_gunlock_q: +out_gunlock_q: gfs2_quota_unlock(ip); - - out: +out: gfs2_alloc_put(ip); - return error; } @@ -884,9 +875,8 @@ static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh, gfs2_trans_add_bh(ip->i_gl, dibh, 1); gfs2_dinode_out(&ip->i_di, dibh->b_data); brelse(dibh); - out: +out: gfs2_trans_end(GFS2_SB(&ip->i_inode)); - return error; } @@ -1025,9 +1015,8 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er, if (private) ea_set_remove_stuffed(ip, (struct gfs2_ea_location *)private); - out: +out: brelse(indbh); - return error; } @@ -1285,15 +1274,13 @@ static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip, brelse(bh[x]); } - out: +out: kfree(bh); - return error; - fail: +fail: gfs2_trans_end(sdp); kfree(bh); - return error; } @@ -1442,15 +1429,12 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip) gfs2_trans_end(sdp); - out_gunlock: +out_gunlock: gfs2_glock_dq_m(rlist.rl_rgrps, rlist.rl_ghs); - - out_rlist_free: +out_rlist_free: gfs2_rlist_free(&rlist); - - out: +out: brelse(indbh); - return error; } @@ -1494,9 +1478,8 @@ static int ea_dealloc_block(struct gfs2_inode *ip) gfs2_trans_end(sdp); - out_gunlock: +out_gunlock: gfs2_glock_dq_uninit(&al->al_rgd_gh); - return error; } @@ -1534,15 +1517,12 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip) error = ea_dealloc_block(ip); - out_rindex: +out_rindex: gfs2_glock_dq_uninit(&al->al_ri_gh); - - out_quota: +out_quota: gfs2_quota_unhold(ip); - - out_alloc: +out_alloc: gfs2_alloc_put(ip); - return error; } diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index fac271f390bfb7..1c916fedc04bef 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -2179,9 +2179,8 @@ static int dump_glock(struct gfs2_glock *gl) error = 0; - out: +out: spin_unlock(&gl->gl_spin); - return error; } diff --git a/fs/gfs2/lm.c b/fs/gfs2/lm.c index fb918c7de655d0..e60f95cae6c552 100644 --- a/fs/gfs2/lm.c +++ b/fs/gfs2/lm.c @@ -76,7 +76,7 @@ int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent) sdp->sd_args.ar_localcaching = 1; } - out: +out: return error; } diff --git a/fs/gfs2/locking/dlm/lock.c b/fs/gfs2/locking/dlm/lock.c index 2d81d90db0970d..1f15b6e8b2cf36 100644 --- a/fs/gfs2/locking/dlm/lock.c +++ b/fs/gfs2/locking/dlm/lock.c @@ -437,7 +437,7 @@ static int hold_null_lock(struct gdlm_lock *lp) gdlm_delete_lp(lpn); lpn = NULL; } - out: +out: lp->hold_null = lpn; return error; } diff --git a/fs/gfs2/locking/dlm/mount.c b/fs/gfs2/locking/dlm/mount.c index f279385774b7ee..82ac00af84a38e 100644 --- a/fs/gfs2/locking/dlm/mount.c +++ b/fs/gfs2/locking/dlm/mount.c @@ -164,13 +164,13 @@ static int gdlm_mount(char *table_name, char *host_data, lockstruct->ls_lvb_size = GDLM_LVB_SIZE; return 0; - out_kobj: +out_kobj: gdlm_kobject_release(ls); - out_thread: +out_thread: gdlm_release_threads(ls); - out_free: +out_free: kfree(ls); - out: +out: return error; } @@ -194,7 +194,7 @@ static void gdlm_unmount(lm_lockspace_t *lockspace) rv = gdlm_release_all_locks(ls); if (rv) log_info("gdlm_unmount: %d stray locks freed", rv); - out: +out: kfree(ls); } diff --git a/fs/gfs2/locking/dlm/thread.c b/fs/gfs2/locking/dlm/thread.c index 0b4be102e1705d..a782246d666bb7 100644 --- a/fs/gfs2/locking/dlm/thread.c +++ b/fs/gfs2/locking/dlm/thread.c @@ -206,7 +206,7 @@ static void process_complete(struct gdlm_lock *lp) if (lp->lksb.sb_flags & DLM_SBF_DEMOTED) set_bit(LFL_NOCACHE, &lp->flags); - out: +out: /* * This is an internal lock_dlm lock */ diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 03850b64c072cf..3f6da00e2f5964 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -756,7 +756,7 @@ void gfs2_meta_ra(struct gfs2_glock *gl, uint64_t dblock, uint32_t extlen) break; } - out: +out: brelse(first_bh); } diff --git a/fs/gfs2/mount.c b/fs/gfs2/mount.c index b66027827aaa26..257c4a179dc6dc 100644 --- a/fs/gfs2/mount.c +++ b/fs/gfs2/mount.c @@ -203,11 +203,11 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount) return error; - need_value: +need_value: fs_info(sdp, "need value for option %s\n", o); return -EINVAL; - cant_remount: +cant_remount: fs_info(sdp, "can't remount with option %s\n", o); return -EINVAL; } diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c index a1ba1ec8eef45d..fa6ceffc7d82e6 100644 --- a/fs/gfs2/ops_dentry.c +++ b/fs/gfs2/ops_dentry.c @@ -81,31 +81,27 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd) goto fail_gunlock; } - valid_gunlock: +valid_gunlock: gfs2_glock_dq_uninit(&d_gh); - - valid: +valid: dput(parent); return 1; - invalid_gunlock: +invalid_gunlock: gfs2_glock_dq_uninit(&d_gh); - - invalid: +invalid: if (inode && S_ISDIR(inode->i_mode)) { if (have_submounts(dentry)) goto valid; shrink_dcache_parent(dentry); } d_drop(dentry); - dput(parent); return 0; - fail_gunlock: +fail_gunlock: gfs2_glock_dq_uninit(&d_gh); - - fail: +fail: dput(parent); return 0; } diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index 07a0c861ac4127..53ce7816dc1899 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c @@ -345,9 +345,8 @@ static int readdir_bad(struct file *file, void *dirent, filldir_t filldir) file->f_pos = offset; - out: +out: kfree(fdb); - return error; } diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 46f910e29bf082..d39314d5dd0ab6 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -173,9 +173,8 @@ static int init_names(struct gfs2_sbd *sdp, int silent) snprintf(sdp->sd_proto_name, GFS2_FSNAME_LEN, "%s", proto); snprintf(sdp->sd_table_name, GFS2_FSNAME_LEN, "%s", table); - out: +out: kfree(sb); - return error; } @@ -246,22 +245,17 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh, fail_trans: gfs2_glock_put(sdp->sd_trans_gl); - fail_rename: gfs2_glock_put(sdp->sd_rename_gl); - fail_live: gfs2_glock_dq_uninit(&sdp->sd_live_gh); - fail_mount: gfs2_glock_dq_uninit(mount_gh); - fail: while (sdp->sd_glockd_num--) kthread_stop(sdp->sd_glockd_process[sdp->sd_glockd_num]); kthread_stop(sdp->sd_scand_process); - return error; } @@ -451,25 +445,20 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) return 0; - fail_recoverd: +fail_recoverd: kthread_stop(sdp->sd_recoverd_process); - - fail_jinode_gh: +fail_jinode_gh: if (!sdp->sd_args.ar_spectator) gfs2_glock_dq_uninit(&sdp->sd_jinode_gh); - - fail_journal_gh: +fail_journal_gh: if (!sdp->sd_args.ar_spectator) gfs2_glock_dq_uninit(&sdp->sd_journal_gh); - - fail_jindex: +fail_jindex: gfs2_jindex_free(sdp); if (jindex) gfs2_glock_dq_uninit(&ji_gh); - - fail: +fail: iput(sdp->sd_jindex); - return error; } @@ -534,14 +523,11 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo) fail_qinode: iput(sdp->sd_quota_inode); - fail_rindex: gfs2_clear_rgrpd(sdp); iput(sdp->sd_rindex); - fail_statfs: iput(sdp->sd_statfs_inode); - fail_inum: iput(sdp->sd_inum_inode); fail_journal: @@ -628,27 +614,19 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) return 0; - fail_qc_gh: +fail_qc_gh: gfs2_glock_dq_uninit(&sdp->sd_qc_gh); - - fail_ut_gh: - +fail_ut_gh: gfs2_glock_dq_uninit(&sdp->sd_sc_gh); - - fail_ir_gh: +fail_ir_gh: gfs2_glock_dq_uninit(&sdp->sd_ir_gh); - - fail_qc_i: +fail_qc_i: iput(sdp->sd_qc_inode); - - fail_ut_i: - +fail_ut_i: iput(sdp->sd_sc_inode); - - fail_ir_i: +fail_ir_i: iput(sdp->sd_ir_inode); - - fail: +fail: if (pn) iput(pn); return error; @@ -781,34 +759,26 @@ static int fill_super(struct super_block *sb, void *data, int silent) return 0; - fail_threads: +fail_threads: init_threads(sdp, UNDO); - - fail_per_node: +fail_per_node: init_per_node(sdp, UNDO); - - fail_inodes: +fail_inodes: init_inodes(sdp, UNDO); - - fail_sb: +fail_sb: init_sb(sdp, 0, UNDO); - - fail_locking: +fail_locking: init_locking(sdp, &mount_gh, UNDO); - - fail_lm: +fail_lm: gfs2_gl_hash_clear(sdp, WAIT); gfs2_lm_unmount(sdp); while (invalidate_inodes(sb)) yield(); - - fail_sys: +fail_sys: gfs2_sys_fs_del(sdp); - - fail: +fail: vfree(sdp); sb->s_fs_info = NULL; - return error; } @@ -852,6 +822,7 @@ static int fill_super_meta(struct super_block *sb, struct super_block *new, return error; } + static int set_bdev_super(struct super_block *s, void *data) { s->s_bdev = data; diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 1786a485acc54c..bd9b9957f707ba 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -228,32 +228,25 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, out_end_trans: gfs2_trans_end(sdp); - out_ipres: if (alloc_required) gfs2_inplace_release(dip); - out_gunlock_q: if (alloc_required) gfs2_quota_unlock(dip); - out_alloc: if (alloc_required) gfs2_alloc_put(dip); - out_gunlock: gfs2_glock_dq_m(2, ghs); - out: gfs2_holder_uninit(ghs); gfs2_holder_uninit(ghs + 1); - if (!error) { atomic_inc(&inode->i_count); d_instantiate(dentry, inode); mark_inode_dirty(inode); } - return error; } @@ -491,13 +484,11 @@ static int gfs2_rmdir(struct inode *dir, struct dentry *dentry) gfs2_trans_end(sdp); - out_gunlock: +out_gunlock: gfs2_glock_dq_m(2, ghs); - - out: +out: gfs2_holder_uninit(ghs); gfs2_holder_uninit(ghs + 1); - return error; } @@ -966,15 +957,12 @@ static int setattr_chown(struct inode *inode, struct iattr *attr) gfs2_quota_change(ip, ip->i_di.di_blocks, nuid, ngid); } - out_end_trans: +out_end_trans: gfs2_trans_end(sdp); - - out_gunlock_q: +out_gunlock_q: gfs2_quota_unlock(ip); - - out_alloc: +out_alloc: gfs2_alloc_put(ip); - return error; } @@ -1017,12 +1005,10 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr) else error = gfs2_setattr_simple(ip, attr); - out: +out: gfs2_glock_dq_uninit(&i_gh); - if (!error) mark_inode_dirty(inode); - return error; } diff --git a/fs/gfs2/ops_vm.c b/fs/gfs2/ops_vm.c index 451f48d62e588b..32ec8574ac8e34 100644 --- a/fs/gfs2/ops_vm.c +++ b/fs/gfs2/ops_vm.c @@ -115,18 +115,14 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page) gfs2_assert_warn(sdp, al->al_alloced); - out_trans: +out_trans: gfs2_trans_end(sdp); - - out_ipres: +out_ipres: gfs2_inplace_release(ip); - - out_gunlock_q: +out_gunlock_q: gfs2_quota_unlock(ip); - - out: +out: gfs2_alloc_put(ip); - return error; } diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index be87983a20a9f3..572b92eac36712 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -105,7 +105,7 @@ static int qd_alloc(struct gfs2_sbd *sdp, int user, uint32_t id, return 0; - fail: +fail: kfree(qd); return error; } @@ -199,7 +199,7 @@ static int slot_get(struct gfs2_quota_data *qd) goto fail; - found: +found: for (b = 0; b < 8; b++) if (!(byte & (1 << b))) break; @@ -214,7 +214,7 @@ static int slot_get(struct gfs2_quota_data *qd) return 0; - fail: +fail: qd->qd_slot_count--; spin_unlock(&sdp->sd_quota_spin); return -ENOSPC; @@ -283,10 +283,9 @@ static int bh_get(struct gfs2_quota_data *qd) return 0; - fail_brelse: +fail_brelse: brelse(bh); - - fail: +fail: qd->qd_bh_count--; mutex_unlock(&sdp->sd_quota_mutex); return error; @@ -425,10 +424,9 @@ static int qdsb_get(struct gfs2_sbd *sdp, int user, uint32_t id, int create, return 0; - fail_slot: +fail_slot: slot_put(*qdp); - - fail: +fail: qd_put(*qdp); return error; } @@ -482,10 +480,9 @@ int gfs2_quota_hold(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) qd++; } - out: +out: if (error) gfs2_quota_unhold(ip); - return error; } @@ -728,26 +725,21 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) error = 0; - out_end_trans: +out_end_trans: gfs2_trans_end(sdp); - - out_ipres: +out_ipres: if (nalloc) gfs2_inplace_release(ip); - - out_alloc: +out_alloc: if (nalloc) gfs2_alloc_put(ip); - - out_gunlock: +out_gunlock: gfs2_glock_dq_uninit(&i_gh); - - out: +out: while (qx--) gfs2_glock_dq_uninit(&ghs[qx]); kfree(ghs); gfs2_log_flush(ip->i_gl->gl_sbd, ip->i_gl); - return error; } @@ -764,7 +756,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, struct gfs2_quota_lvb *qlvb; file_ra_state_init(&ra_state, sdp->sd_quota_inode->i_mapping); - restart: +restart: error = gfs2_glock_nq_init(qd->qd_gl, LM_ST_SHARED, 0, q_gh); if (error) return error; @@ -812,12 +804,10 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, return 0; - fail_gunlock: +fail_gunlock: gfs2_glock_dq_uninit(&i_gh); - - fail: +fail: gfs2_glock_dq_uninit(q_gh); - return error; } @@ -919,7 +909,7 @@ void gfs2_quota_unlock(struct gfs2_inode *ip) qd_unlock(qda[x]); } - out: +out: gfs2_quota_unhold(ip); } @@ -1098,9 +1088,8 @@ int gfs2_quota_read(struct gfs2_sbd *sdp, int user, uint32_t id, gfs2_glock_dq_uninit(&q_gh); - out: +out: qd_put(qd); - return error; } #endif /* 0 */ @@ -1202,7 +1191,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp) return 0; - fail: +fail: gfs2_quota_cleanup(sdp); return error; } diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index e93066f930c1be..520266c2044b28 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -535,7 +535,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp) error = gfs2_quota_init(sdp); if (error) - goto fail_unlinked; + goto fail; set_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags); @@ -543,9 +543,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp) return 0; - fail_unlinked: - - fail: +fail: t_gh.gh_flags |= GL_NOCACHE; gfs2_glock_dq_uninit(&t_gh); @@ -625,12 +623,10 @@ int gfs2_statfs_init(struct gfs2_sbd *sdp) brelse(l_bh); } - out_m_bh: +out_m_bh: brelse(m_bh); - - out: +out: gfs2_glock_dq_uninit(&gh); - return 0; } @@ -715,15 +711,12 @@ int gfs2_statfs_sync(struct gfs2_sbd *sdp) gfs2_trans_end(sdp); - out_bh2: +out_bh2: brelse(l_bh); - - out_bh: +out_bh: brelse(m_bh); - - out: +out: gfs2_glock_dq_uninit(&gh); - return error; } @@ -853,9 +846,8 @@ int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc) gfs2_glock_dq_uninit(&ri_gh); - out: +out: kfree(gha); - return error; } @@ -924,7 +916,7 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, if (error) gfs2_glock_dq_uninit(t_gh); - out: +out: while (!list_empty(&list)) { lfcc = list_entry(list.next, struct lfcc, list); list_del(&lfcc->list); @@ -932,7 +924,6 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, kfree(lfcc); } gfs2_glock_dq_uninit(&ji_gh); - return error; } diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index 3ffa88506c447a..79199738c3891c 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c @@ -543,15 +543,15 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp) return 0; - fail_args: +fail_args: sysfs_remove_group(&sdp->sd_kobj, &args_group); - fail_counters: +fail_counters: sysfs_remove_group(&sdp->sd_kobj, &counters_group); - fail_lockstruct: +fail_lockstruct: sysfs_remove_group(&sdp->sd_kobj, &lockstruct_group); - fail_reg: +fail_reg: kobject_unregister(&sdp->sd_kobj); - fail: +fail: return error; } -- cgit 1.2.3-korg From cd915493fce912f1bd838ee1250737ecf33b8fae Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Mon, 4 Sep 2006 12:49:07 -0400 Subject: [GFS2] Change all types to uX style This makes all fixed size types have consistent names. Cc: Jan Engelhardt Signed-off-by: Steven Whitehouse --- fs/gfs2/bmap.c | 60 ++++++++++---------- fs/gfs2/bmap.h | 4 +- fs/gfs2/dir.c | 124 ++++++++++++++++++++--------------------- fs/gfs2/dir.h | 8 +-- fs/gfs2/eattr.c | 56 +++++++++---------- fs/gfs2/eattr.h | 6 +- fs/gfs2/glock.c | 8 +-- fs/gfs2/glock.h | 6 +- fs/gfs2/incore.h | 72 ++++++++++++------------ fs/gfs2/inode.c | 20 +++---- fs/gfs2/lm_interface.h | 2 +- fs/gfs2/locking/dlm/lock.c | 8 +-- fs/gfs2/locking/dlm/lock_dlm.h | 14 ++--- fs/gfs2/locking/dlm/thread.c | 2 +- fs/gfs2/log.c | 18 +++--- fs/gfs2/lops.c | 18 +++--- fs/gfs2/meta_io.c | 18 +++--- fs/gfs2/meta_io.h | 10 ++-- fs/gfs2/ops_address.c | 8 +-- fs/gfs2/ops_export.c | 12 ++-- fs/gfs2/ops_file.c | 10 ++-- fs/gfs2/ops_inode.c | 12 ++-- fs/gfs2/ops_vm.c | 4 +- fs/gfs2/quota.c | 50 ++++++++--------- fs/gfs2/quota.h | 14 ++--- fs/gfs2/recovery.c | 16 +++--- fs/gfs2/recovery.h | 4 +- fs/gfs2/rgrp.c | 72 ++++++++++++------------ fs/gfs2/rgrp.h | 10 ++-- fs/gfs2/super.c | 28 +++++----- fs/gfs2/super.h | 2 +- fs/gfs2/sys.c | 4 +- fs/gfs2/trans.c | 6 +- fs/gfs2/trans.h | 4 +- fs/gfs2/util.c | 2 +- fs/gfs2/util.h | 14 ++--- 36 files changed, 363 insertions(+), 363 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index bb597839c0c9b8..a97ad74d880cb2 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -38,8 +38,8 @@ struct metapath { }; typedef int (*block_call_t) (struct gfs2_inode *ip, struct buffer_head *dibh, - struct buffer_head *bh, uint64_t *top, - uint64_t *bottom, unsigned int height, + struct buffer_head *bh, u64 *top, + u64 *bottom, unsigned int height, void *data); struct strip_mine { @@ -58,7 +58,7 @@ struct strip_mine { */ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, - uint64_t block, struct page *page) + u64 block, struct page *page) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct inode *inode = &ip->i_inode; @@ -121,7 +121,7 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) { struct buffer_head *bh, *dibh; - uint64_t block = 0; + u64 block = 0; int isdir = gfs2_is_dir(ip); int error; @@ -161,7 +161,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); if (ip->i_di.di_size) { - *(uint64_t *)(dibh->b_data + sizeof(struct gfs2_dinode)) = + *(u64 *)(dibh->b_data + sizeof(struct gfs2_dinode)) = cpu_to_be64(block); ip->i_di.di_blocks++; } @@ -190,10 +190,10 @@ out: * Returns: the height the tree should be */ -static unsigned int calc_tree_height(struct gfs2_inode *ip, uint64_t size) +static unsigned int calc_tree_height(struct gfs2_inode *ip, u64 size) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); - uint64_t *arr; + u64 *arr; unsigned int max, height; if (ip->i_di.di_size > size) @@ -336,11 +336,11 @@ static int build_height(struct inode *inode, unsigned height) * */ -static void find_metapath(struct gfs2_inode *ip, uint64_t block, +static void find_metapath(struct gfs2_inode *ip, u64 block, struct metapath *mp) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); - uint64_t b = block; + u64 b = block; unsigned int i; for (i = ip->i_di.di_height; i--;) @@ -390,10 +390,10 @@ static inline u64 *metapointer(struct buffer_head *bh, int *boundary, static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh, unsigned int height, struct metapath *mp, int create, - int *new, uint64_t *block) + int *new, u64 *block) { int boundary; - uint64_t *ptr = metapointer(bh, &boundary, height, mp); + u64 *ptr = metapointer(bh, &boundary, height, mp); if (*ptr) { *block = be64_to_cpu(*ptr); @@ -594,13 +594,13 @@ int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsi static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh, struct metapath *mp, unsigned int height, - uint64_t block, int first, block_call_t bc, + u64 block, int first, block_call_t bc, void *data) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head *bh = NULL; - uint64_t *top, *bottom; - uint64_t bn; + u64 *top, *bottom; + u64 bn; int error; int mh_size = sizeof(struct gfs2_meta_header); @@ -617,10 +617,10 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh, if (error) return error; - top = (uint64_t *)(bh->b_data + mh_size) + + top = (u64 *)(bh->b_data + mh_size) + ((first) ? mp->mp_list[height] : 0); - bottom = (uint64_t *)(bh->b_data + mh_size) + sdp->sd_inptrs; + bottom = (u64 *)(bh->b_data + mh_size) + sdp->sd_inptrs; } error = bc(ip, dibh, bh, top, bottom, height, data); @@ -659,15 +659,15 @@ out: */ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, - struct buffer_head *bh, uint64_t *top, uint64_t *bottom, + struct buffer_head *bh, u64 *top, u64 *bottom, unsigned int height, void *data) { struct strip_mine *sm = data; struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_rgrp_list rlist; - uint64_t bn, bstart; - uint32_t blen; - uint64_t *p; + u64 bn, bstart; + u32 blen; + u64 *p; unsigned int rg_blocks = 0; int metadata; unsigned int revokes = 0; @@ -804,7 +804,7 @@ out: * Returns: errno */ -static int do_grow(struct gfs2_inode *ip, uint64_t size) +static int do_grow(struct gfs2_inode *ip, u64 size) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al; @@ -949,7 +949,7 @@ unlock: return err; } -static int trunc_start(struct gfs2_inode *ip, uint64_t size) +static int trunc_start(struct gfs2_inode *ip, u64 size) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head *dibh; @@ -974,7 +974,7 @@ static int trunc_start(struct gfs2_inode *ip, uint64_t size) error = 1; } else { - if (size & (uint64_t)(sdp->sd_sb.sb_bsize - 1)) + if (size & (u64)(sdp->sd_sb.sb_bsize - 1)) error = gfs2_block_truncate_page(ip->i_inode.i_mapping); if (!error) { @@ -993,10 +993,10 @@ out: return error; } -static int trunc_dealloc(struct gfs2_inode *ip, uint64_t size) +static int trunc_dealloc(struct gfs2_inode *ip, u64 size) { unsigned int height = ip->i_di.di_height; - uint64_t lblock; + u64 lblock; struct metapath mp; int error; @@ -1076,7 +1076,7 @@ out: * Returns: errno */ -static int do_shrink(struct gfs2_inode *ip, uint64_t size) +static int do_shrink(struct gfs2_inode *ip, u64 size) { int error; @@ -1104,7 +1104,7 @@ static int do_shrink(struct gfs2_inode *ip, uint64_t size) * Returns: errno */ -int gfs2_truncatei(struct gfs2_inode *ip, uint64_t size) +int gfs2_truncatei(struct gfs2_inode *ip, u64 size) { int error; @@ -1172,12 +1172,12 @@ void gfs2_write_calc_reserv(struct gfs2_inode *ip, unsigned int len, * Returns: errno */ -int gfs2_write_alloc_required(struct gfs2_inode *ip, uint64_t offset, +int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, unsigned int len, int *alloc_required) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); - uint64_t lblock, lblock_stop, dblock; - uint32_t extlen; + u64 lblock, lblock_stop, dblock; + u32 extlen; int new = 0; int error = 0; diff --git a/fs/gfs2/bmap.h b/fs/gfs2/bmap.h index ab0157c5ed0e5a..cb3b624fea3132 100644 --- a/fs/gfs2/bmap.h +++ b/fs/gfs2/bmap.h @@ -14,14 +14,14 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page); int gfs2_block_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, int *boundary); int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen); -int gfs2_truncatei(struct gfs2_inode *ip, uint64_t size); +int gfs2_truncatei(struct gfs2_inode *ip, u64 size); int gfs2_truncatei_resume(struct gfs2_inode *ip); int gfs2_file_dealloc(struct gfs2_inode *ip); void gfs2_write_calc_reserv(struct gfs2_inode *ip, unsigned int len, unsigned int *data_blocks, unsigned int *ind_blocks); -int gfs2_write_alloc_required(struct gfs2_inode *ip, uint64_t offset, +int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, unsigned int len, int *alloc_required); #endif /* __BMAP_DOT_H__ */ diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 59d0cbcaecffc1..2023dc4ea30667 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -78,15 +78,15 @@ #define IS_LEAF 1 /* Hashed (leaf) directory */ #define IS_DINODE 2 /* Linear (stuffed dinode block) directory */ -#define gfs2_disk_hash2offset(h) (((uint64_t)(h)) >> 1) -#define gfs2_dir_offset2hash(p) ((uint32_t)(((uint64_t)(p)) << 1)) +#define gfs2_disk_hash2offset(h) (((u64)(h)) >> 1) +#define gfs2_dir_offset2hash(p) ((u32)(((u64)(p)) << 1)) typedef int (*leaf_call_t) (struct gfs2_inode *dip, - uint32_t index, uint32_t len, uint64_t leaf_no, + u32 index, u32 len, u64 leaf_no, void *data); -int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, uint64_t block, +int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, u64 block, struct buffer_head **bhp) { struct buffer_head *bh; @@ -99,7 +99,7 @@ int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, uint64_t block, return 0; } -static int gfs2_dir_get_existing_buffer(struct gfs2_inode *ip, uint64_t block, +static int gfs2_dir_get_existing_buffer(struct gfs2_inode *ip, u64 block, struct buffer_head **bhp) { struct buffer_head *bh; @@ -151,12 +151,12 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf, * Returns: The number of bytes correctly written or error code */ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf, - uint64_t offset, unsigned int size) + u64 offset, unsigned int size) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head *dibh; - uint64_t lblock, dblock; - uint32_t extlen = 0; + u64 lblock, dblock; + u32 extlen = 0; unsigned int o; int copied = 0; int error = 0; @@ -271,11 +271,11 @@ static int gfs2_dir_read_stuffed(struct gfs2_inode *ip, char *buf, * Returns: The amount of data actually copied or the error */ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, - uint64_t offset, unsigned int size) + u64 offset, unsigned int size) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); - uint64_t lblock, dblock; - uint32_t extlen = 0; + u64 lblock, dblock; + u32 extlen = 0; unsigned int o; int copied = 0; int error = 0; @@ -581,7 +581,7 @@ static int dirent_next(struct gfs2_inode *dip, struct buffer_head *bh, { struct gfs2_dirent *tmp, *cur; char *bh_end; - uint16_t cur_rec_len; + u16 cur_rec_len; cur = *dent; bh_end = bh->b_data + bh->b_size; @@ -630,7 +630,7 @@ static int dirent_next(struct gfs2_inode *dip, struct buffer_head *bh, static void dirent_del(struct gfs2_inode *dip, struct buffer_head *bh, struct gfs2_dirent *prev, struct gfs2_dirent *cur) { - uint16_t cur_rec_len, prev_rec_len; + u16 cur_rec_len, prev_rec_len; if (!cur->de_inum.no_addr) { gfs2_consist_inode(dip); @@ -698,7 +698,7 @@ static struct gfs2_dirent *gfs2_dirent_alloc(struct inode *inode, return gfs2_init_dirent(inode, dent, name, bh); } -static int get_leaf(struct gfs2_inode *dip, uint64_t leaf_no, +static int get_leaf(struct gfs2_inode *dip, u64 leaf_no, struct buffer_head **bhp) { int error; @@ -721,16 +721,16 @@ static int get_leaf(struct gfs2_inode *dip, uint64_t leaf_no, * Returns: 0 on success, error code otherwise */ -static int get_leaf_nr(struct gfs2_inode *dip, uint32_t index, - uint64_t *leaf_out) +static int get_leaf_nr(struct gfs2_inode *dip, u32 index, + u64 *leaf_out) { - uint64_t leaf_no; + u64 leaf_no; int error; error = gfs2_dir_read_data(dip, (char *)&leaf_no, - index * sizeof(uint64_t), - sizeof(uint64_t)); - if (error != sizeof(uint64_t)) + index * sizeof(u64), + sizeof(u64)); + if (error != sizeof(u64)) return (error < 0) ? error : -EIO; *leaf_out = be64_to_cpu(leaf_no); @@ -738,10 +738,10 @@ static int get_leaf_nr(struct gfs2_inode *dip, uint32_t index, return 0; } -static int get_first_leaf(struct gfs2_inode *dip, uint32_t index, +static int get_first_leaf(struct gfs2_inode *dip, u32 index, struct buffer_head **bh_out) { - uint64_t leaf_no; + u64 leaf_no; int error; error = get_leaf_nr(dip, index, &leaf_no); @@ -847,8 +847,8 @@ static int dir_make_exhash(struct inode *inode) struct buffer_head *bh, *dibh; struct gfs2_leaf *leaf; int y; - uint32_t x; - uint64_t *lp, bn; + u32 x; + u64 *lp, bn; int error; error = gfs2_meta_inode_buffer(dip, &dibh); @@ -904,7 +904,7 @@ static int dir_make_exhash(struct inode *inode) gfs2_trans_add_bh(dip->i_gl, dibh, 1); gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); - lp = (uint64_t *)(dibh->b_data + sizeof(struct gfs2_dinode)); + lp = (u64 *)(dibh->b_data + sizeof(struct gfs2_dinode)); for (x = sdp->sd_hash_ptrs; x--; lp++) *lp = cpu_to_be64(bn); @@ -939,9 +939,9 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name) struct buffer_head *nbh, *obh, *dibh; struct gfs2_leaf *nleaf, *oleaf; struct gfs2_dirent *dent = NULL, *prev = NULL, *next = NULL, *new; - uint32_t start, len, half_len, divider; - uint64_t bn, *lp, leaf_no; - uint32_t index; + u32 start, len, half_len, divider; + u64 bn, *lp, leaf_no; + u32 index; int x, moved = 0; int error; @@ -985,14 +985,14 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name) /* Change the pointers. Don't bother distinguishing stuffed from non-stuffed. This code is complicated enough already. */ - lp = kmalloc(half_len * sizeof(uint64_t), GFP_NOFS | __GFP_NOFAIL); + lp = kmalloc(half_len * sizeof(u64), GFP_NOFS | __GFP_NOFAIL); /* Change the pointers */ for (x = 0; x < half_len; x++) lp[x] = cpu_to_be64(bn); - error = gfs2_dir_write_data(dip, (char *)lp, start * sizeof(uint64_t), - half_len * sizeof(uint64_t)); - if (error != half_len * sizeof(uint64_t)) { + error = gfs2_dir_write_data(dip, (char *)lp, start * sizeof(u64), + half_len * sizeof(u64)); + if (error != half_len * sizeof(u64)) { if (error >= 0) error = -EIO; goto fail_lpfree; @@ -1077,15 +1077,15 @@ static int dir_double_exhash(struct gfs2_inode *dip) { struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); struct buffer_head *dibh; - uint32_t hsize; - uint64_t *buf; - uint64_t *from, *to; - uint64_t block; + u32 hsize; + u64 *buf; + u64 *from, *to; + u64 block; int x; int error = 0; hsize = 1 << dip->i_di.di_depth; - if (hsize * sizeof(uint64_t) != dip->i_di.di_size) { + if (hsize * sizeof(u64) != dip->i_di.di_size) { gfs2_consist_inode(dip); return -EIO; } @@ -1105,7 +1105,7 @@ static int dir_double_exhash(struct gfs2_inode *dip) } from = buf; - to = (uint64_t *)((char *)buf + sdp->sd_hash_bsize); + to = (u64 *)((char *)buf + sdp->sd_hash_bsize); for (x = sdp->sd_hash_ptrs; x--; from++) { *to++ = *from; /* No endianess worries */ @@ -1153,7 +1153,7 @@ fail: static int compare_dents(const void *a, const void *b) { struct gfs2_dirent *dent_a, *dent_b; - uint32_t hash_a, hash_b; + u32 hash_a, hash_b; int ret = 0; dent_a = *(struct gfs2_dirent **)a; @@ -1201,14 +1201,14 @@ static int compare_dents(const void *a, const void *b) * Returns: errno, >0 on exception from filldir */ -static int do_filldir_main(struct gfs2_inode *dip, uint64_t *offset, +static int do_filldir_main(struct gfs2_inode *dip, u64 *offset, void *opaque, gfs2_filldir_t filldir, - const struct gfs2_dirent **darr, uint32_t entries, + const struct gfs2_dirent **darr, u32 entries, int *copied) { const struct gfs2_dirent *dent, *dent_next; struct gfs2_inum inum; - uint64_t off, off_next; + u64 off, off_next; unsigned int x, y; int run = 0; int error = 0; @@ -1346,21 +1346,21 @@ out: * Returns: errno */ -static int dir_e_read(struct inode *inode, uint64_t *offset, void *opaque, +static int dir_e_read(struct inode *inode, u64 *offset, void *opaque, gfs2_filldir_t filldir) { struct gfs2_inode *dip = GFS2_I(inode); struct gfs2_sbd *sdp = GFS2_SB(inode); - uint32_t hsize, len = 0; - uint32_t ht_offset, lp_offset, ht_offset_cur = -1; - uint32_t hash, index; - uint64_t *lp; + u32 hsize, len = 0; + u32 ht_offset, lp_offset, ht_offset_cur = -1; + u32 hash, index; + u64 *lp; int copied = 0; int error = 0; unsigned depth = 0; hsize = 1 << dip->i_di.di_depth; - if (hsize * sizeof(uint64_t) != dip->i_di.di_size) { + if (hsize * sizeof(u64) != dip->i_di.di_size) { gfs2_consist_inode(dip); return -EIO; } @@ -1378,7 +1378,7 @@ static int dir_e_read(struct inode *inode, uint64_t *offset, void *opaque, if (ht_offset_cur != ht_offset) { error = gfs2_dir_read_data(dip, (char *)lp, - ht_offset * sizeof(uint64_t), + ht_offset * sizeof(u64), sdp->sd_hash_bsize); if (error != sdp->sd_hash_bsize) { if (error >= 0) @@ -1405,7 +1405,7 @@ out: return error; } -int gfs2_dir_read(struct inode *inode, uint64_t *offset, void *opaque, +int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque, gfs2_filldir_t filldir) { struct gfs2_inode *dip = GFS2_I(inode); @@ -1725,15 +1725,15 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data) struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); struct buffer_head *bh; struct gfs2_leaf *leaf; - uint32_t hsize, len; - uint32_t ht_offset, lp_offset, ht_offset_cur = -1; - uint32_t index = 0; - uint64_t *lp; - uint64_t leaf_no; + u32 hsize, len; + u32 ht_offset, lp_offset, ht_offset_cur = -1; + u32 index = 0; + u64 *lp; + u64 leaf_no; int error = 0; hsize = 1 << dip->i_di.di_depth; - if (hsize * sizeof(uint64_t) != dip->i_di.di_size) { + if (hsize * sizeof(u64) != dip->i_di.di_size) { gfs2_consist_inode(dip); return -EIO; } @@ -1748,7 +1748,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data) if (ht_offset_cur != ht_offset) { error = gfs2_dir_read_data(dip, (char *)lp, - ht_offset * sizeof(uint64_t), + ht_offset * sizeof(u64), sdp->sd_hash_bsize); if (error != sdp->sd_hash_bsize) { if (error >= 0) @@ -1798,17 +1798,17 @@ out: * Returns: errno */ -static int leaf_dealloc(struct gfs2_inode *dip, uint32_t index, uint32_t len, - uint64_t leaf_no, void *data) +static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, + u64 leaf_no, void *data) { struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); struct gfs2_leaf *tmp_leaf; struct gfs2_rgrp_list rlist; struct buffer_head *bh, *dibh; - uint64_t blk, nblk; + u64 blk, nblk; unsigned int rg_blocks = 0, l_blocks = 0; char *ht; - unsigned int x, size = len * sizeof(uint64_t); + unsigned int x, size = len * sizeof(u64); int error; memset(&rlist, 0, sizeof(struct gfs2_rgrp_list)); @@ -1874,7 +1874,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, uint32_t index, uint32_t len, dip->i_di.di_blocks--; } - error = gfs2_dir_write_data(dip, ht, index * sizeof(uint64_t), size); + error = gfs2_dir_write_data(dip, ht, index * sizeof(u64), size); if (error != size) { if (error >= 0) error = -EIO; diff --git a/fs/gfs2/dir.h b/fs/gfs2/dir.h index 366a5571648f61..f1f83faa36ecb0 100644 --- a/fs/gfs2/dir.h +++ b/fs/gfs2/dir.h @@ -24,7 +24,7 @@ typedef int (*gfs2_filldir_t) (void *opaque, const char *name, unsigned int length, - uint64_t offset, + u64 offset, struct gfs2_inum *inum, unsigned int type); int gfs2_dir_search(struct inode *dir, const struct qstr *filename, @@ -32,7 +32,7 @@ int gfs2_dir_search(struct inode *dir, const struct qstr *filename, int gfs2_dir_add(struct inode *inode, const struct qstr *filename, const struct gfs2_inum *inum, unsigned int type); int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *filename); -int gfs2_dir_read(struct inode *inode, uint64_t * offset, void *opaque, +int gfs2_dir_read(struct inode *inode, u64 * offset, void *opaque, gfs2_filldir_t filldir); int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename, struct gfs2_inum *new_inum, unsigned int new_type); @@ -41,10 +41,10 @@ int gfs2_dir_exhash_dealloc(struct gfs2_inode *dip); int gfs2_diradd_alloc_required(struct inode *dir, const struct qstr *filename); -int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, uint64_t block, +int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, u64 block, struct buffer_head **bhp); -static inline uint32_t gfs2_disk_hash(const char *data, int len) +static inline u32 gfs2_disk_hash(const char *data, int len) { return crc32_le(0xFFFFFFFF, data, len) ^ 0xFFFFFFFF; } diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c index 5a56e6568622b0..f6b5e306a6c8ca 100644 --- a/fs/gfs2/eattr.c +++ b/fs/gfs2/eattr.c @@ -115,7 +115,7 @@ fail: static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data) { struct buffer_head *bh, *eabh; - uint64_t *eablk, *end; + u64 *eablk, *end; int error; error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, @@ -133,11 +133,11 @@ static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data) goto out; } - eablk = (uint64_t *)(bh->b_data + sizeof(struct gfs2_meta_header)); + eablk = (u64 *)(bh->b_data + sizeof(struct gfs2_meta_header)); end = eablk + GFS2_SB(&ip->i_inode)->sd_inptrs; for (; eablk < end; eablk++) { - uint64_t bn; + u64 bn; if (!*eablk) break; @@ -235,8 +235,8 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, struct gfs2_rgrpd *rgd; struct gfs2_holder rg_gh; struct buffer_head *dibh; - uint64_t *dataptrs, bn = 0; - uint64_t bstart = 0; + u64 *dataptrs, bn = 0; + u64 bstart = 0; unsigned int blen = 0; unsigned int blks = 0; unsigned int x; @@ -296,7 +296,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, gfs2_free_meta(ip, bstart, blen); if (prev && !leave) { - uint32_t len; + u32 len; len = GFS2_EA_REC_LEN(prev) + GFS2_EA_REC_LEN(ea); prev->ea_rec_len = cpu_to_be32(len); @@ -459,7 +459,7 @@ static int ea_get_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea, struct buffer_head **bh; unsigned int amount = GFS2_EA_DATA_LEN(ea); unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize); - uint64_t *dataptrs = GFS2_EA2DATAPTRS(ea); + u64 *dataptrs = GFS2_EA2DATAPTRS(ea); unsigned int x; int error = 0; @@ -601,7 +601,7 @@ static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_ea_header *ea; - uint64_t block; + u64 block; block = gfs2_alloc_meta(ip); @@ -649,7 +649,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea, ea->ea_num_ptrs = 0; memcpy(GFS2_EA2DATA(ea), er->er_data, er->er_data_len); } else { - uint64_t *dataptr = GFS2_EA2DATAPTRS(ea); + u64 *dataptr = GFS2_EA2DATAPTRS(ea); const char *data = er->er_data; unsigned int data_len = er->er_data_len; unsigned int copy; @@ -658,7 +658,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea, ea->ea_num_ptrs = DIV_ROUND_UP(er->er_data_len, sdp->sd_jbsize); for (x = 0; x < ea->ea_num_ptrs; x++) { struct buffer_head *bh; - uint64_t block; + u64 block; int mh_size = sizeof(struct gfs2_meta_header); block = gfs2_alloc_meta(ip); @@ -676,7 +676,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea, memset(bh->b_data + mh_size + copy, 0, sdp->sd_jbsize - copy); - *dataptr++ = cpu_to_be64((uint64_t)bh->b_blocknr); + *dataptr++ = cpu_to_be64((u64)bh->b_blocknr); data += copy; data_len -= copy; @@ -792,10 +792,10 @@ static int ea_init(struct gfs2_inode *ip, struct gfs2_ea_request *er) static struct gfs2_ea_header *ea_split_ea(struct gfs2_ea_header *ea) { - uint32_t ea_size = GFS2_EA_SIZE(ea); + u32 ea_size = GFS2_EA_SIZE(ea); struct gfs2_ea_header *new = (struct gfs2_ea_header *)((char *)ea + ea_size); - uint32_t new_size = GFS2_EA_REC_LEN(ea) - ea_size; + u32 new_size = GFS2_EA_REC_LEN(ea) - ea_size; int last = ea->ea_flags & GFS2_EAFLAG_LAST; ea->ea_rec_len = cpu_to_be32(ea_size); @@ -812,7 +812,7 @@ static void ea_set_remove_stuffed(struct gfs2_inode *ip, { struct gfs2_ea_header *ea = el->el_ea; struct gfs2_ea_header *prev = el->el_prev; - uint32_t len; + u32 len; gfs2_trans_add_bh(ip->i_gl, el->el_bh, 1); @@ -953,12 +953,12 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er, { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head *indbh, *newbh; - uint64_t *eablk; + u64 *eablk; int error; int mh_size = sizeof(struct gfs2_meta_header); if (ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT) { - uint64_t *end; + u64 *end; error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_START | DIO_WAIT, &indbh); @@ -970,7 +970,7 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er, goto out; } - eablk = (uint64_t *)(indbh->b_data + mh_size); + eablk = (u64 *)(indbh->b_data + mh_size); end = eablk + sdp->sd_inptrs; for (; eablk < end; eablk++) @@ -984,7 +984,7 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er, gfs2_trans_add_bh(ip->i_gl, indbh, 1); } else { - uint64_t blk; + u64 blk; blk = gfs2_alloc_meta(ip); @@ -993,7 +993,7 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er, gfs2_metatype_set(indbh, GFS2_METATYPE_IN, GFS2_FORMAT_IN); gfs2_buffer_clear_tail(indbh, mh_size); - eablk = (uint64_t *)(indbh->b_data + mh_size); + eablk = (u64 *)(indbh->b_data + mh_size); *eablk = cpu_to_be64(ip->i_di.di_eattr); ip->i_di.di_eattr = blk; ip->i_di.di_flags |= GFS2_DIF_EA_INDIRECT; @@ -1006,7 +1006,7 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er, if (error) goto out; - *eablk = cpu_to_be64((uint64_t)newbh->b_blocknr); + *eablk = cpu_to_be64((u64)newbh->b_blocknr); error = ea_write(ip, GFS2_EA_BH2FIRST(newbh), er); brelse(newbh); if (error) @@ -1140,7 +1140,7 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el) gfs2_trans_add_bh(ip->i_gl, el->el_bh, 1); if (prev) { - uint32_t len; + u32 len; len = GFS2_EA_REC_LEN(prev) + GFS2_EA_REC_LEN(ea); prev->ea_rec_len = cpu_to_be32(len); @@ -1225,7 +1225,7 @@ static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip, struct buffer_head **bh; unsigned int amount = GFS2_EA_DATA_LEN(ea); unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize); - uint64_t *dataptrs = GFS2_EA2DATAPTRS(ea); + u64 *dataptrs = GFS2_EA2DATAPTRS(ea); unsigned int x; int error; @@ -1325,9 +1325,9 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip) struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_rgrp_list rlist; struct buffer_head *indbh, *dibh; - uint64_t *eablk, *end; + u64 *eablk, *end; unsigned int rg_blocks = 0; - uint64_t bstart = 0; + u64 bstart = 0; unsigned int blen = 0; unsigned int blks = 0; unsigned int x; @@ -1345,11 +1345,11 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip) goto out; } - eablk = (uint64_t *)(indbh->b_data + sizeof(struct gfs2_meta_header)); + eablk = (u64 *)(indbh->b_data + sizeof(struct gfs2_meta_header)); end = eablk + sdp->sd_inptrs; for (; eablk < end; eablk++) { - uint64_t bn; + u64 bn; if (!*eablk) break; @@ -1390,12 +1390,12 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip) gfs2_trans_add_bh(ip->i_gl, indbh, 1); - eablk = (uint64_t *)(indbh->b_data + sizeof(struct gfs2_meta_header)); + eablk = (u64 *)(indbh->b_data + sizeof(struct gfs2_meta_header)); bstart = 0; blen = 0; for (; eablk < end; eablk++) { - uint64_t bn; + u64 bn; if (!*eablk) break; diff --git a/fs/gfs2/eattr.h b/fs/gfs2/eattr.h index 7b0291f99fd9fa..85c70c335c59c4 100644 --- a/fs/gfs2/eattr.h +++ b/fs/gfs2/eattr.h @@ -16,7 +16,7 @@ #define GFS2_EA_SIZE(ea) \ ALIGN(sizeof(struct gfs2_ea_header) + (ea)->ea_name_len + \ ((GFS2_EA_IS_STUFFED(ea)) ? GFS2_EA_DATA_LEN(ea) : \ - (sizeof(uint64_t) * (ea)->ea_num_ptrs)), 8) + (sizeof(u64) * (ea)->ea_num_ptrs)), 8) #define GFS2_EA_IS_STUFFED(ea) (!(ea)->ea_num_ptrs) #define GFS2_EA_IS_LAST(ea) ((ea)->ea_flags & GFS2_EAFLAG_LAST) @@ -26,13 +26,13 @@ ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + (er)->er_data_len, 8) #define GFS2_EAREQ_SIZE_UNSTUFFED(sdp, er) \ ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + \ - sizeof(uint64_t) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8) + sizeof(u64) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8) #define GFS2_EA2NAME(ea) ((char *)((struct gfs2_ea_header *)(ea) + 1)) #define GFS2_EA2DATA(ea) (GFS2_EA2NAME(ea) + (ea)->ea_name_len) #define GFS2_EA2DATAPTRS(ea) \ -((uint64_t *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8))) +((u64 *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8))) #define GFS2_EA2NEXT(ea) \ ((struct gfs2_ea_header *)((char *)(ea) + GFS2_EA_REC_LEN(ea))) diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 1c916fedc04bef..f2edc8b761217d 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -87,7 +87,7 @@ static unsigned int gl_hash(const struct lm_lockname *name) { unsigned int h; - h = jhash(&name->ln_number, sizeof(uint64_t), 0); + h = jhash(&name->ln_number, sizeof(u64), 0); h = jhash(&name->ln_type, sizeof(unsigned int), h); h &= GFS2_GL_HASH_MASK; @@ -255,7 +255,7 @@ static struct gfs2_glock *gfs2_glock_find(struct gfs2_sbd *sdp, * Returns: errno */ -int gfs2_glock_get(struct gfs2_sbd *sdp, uint64_t number, +int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, const struct gfs2_glock_operations *glops, int create, struct gfs2_glock **glp) { @@ -1415,7 +1415,7 @@ void gfs2_glock_dq_uninit(struct gfs2_holder *gh) * Returns: errno */ -int gfs2_glock_nq_num(struct gfs2_sbd *sdp, uint64_t number, +int gfs2_glock_nq_num(struct gfs2_sbd *sdp, u64 number, const struct gfs2_glock_operations *glops, unsigned int state, int flags, struct gfs2_holder *gh) { @@ -1613,7 +1613,7 @@ void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs) * Returns: errno */ -void gfs2_glock_prefetch_num(struct gfs2_sbd *sdp, uint64_t number, +void gfs2_glock_prefetch_num(struct gfs2_sbd *sdp, u64 number, const struct gfs2_glock_operations *glops, unsigned int state, int flags) { diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 1a90a1983bebec..4762cdb04f64ac 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -74,7 +74,7 @@ static inline int gfs2_glock_is_blocking(struct gfs2_glock *gl) } int gfs2_glock_get(struct gfs2_sbd *sdp, - uint64_t number, const struct gfs2_glock_operations *glops, + u64 number, const struct gfs2_glock_operations *glops, int create, struct gfs2_glock **glp); void gfs2_glock_hold(struct gfs2_glock *gl); int gfs2_glock_put(struct gfs2_glock *gl); @@ -96,14 +96,14 @@ int gfs2_glock_be_greedy(struct gfs2_glock *gl, unsigned int time); void gfs2_glock_dq_uninit(struct gfs2_holder *gh); int gfs2_glock_nq_num(struct gfs2_sbd *sdp, - uint64_t number, const struct gfs2_glock_operations *glops, + u64 number, const struct gfs2_glock_operations *glops, unsigned int state, int flags, struct gfs2_holder *gh); int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs); void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs); void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs); -void gfs2_glock_prefetch_num(struct gfs2_sbd *sdp, uint64_t number, +void gfs2_glock_prefetch_num(struct gfs2_sbd *sdp, u64 number, const struct gfs2_glock_operations *glops, unsigned int state, int flags); void gfs2_glock_inode_squish(struct inode *inode); diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 06f5ec6ebf7faf..407afd18fa2eef 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -60,9 +60,9 @@ struct gfs2_log_element { struct gfs2_bitmap { struct buffer_head *bi_bh; char *bi_clone; - uint32_t bi_offset; - uint32_t bi_start; - uint32_t bi_len; + u32 bi_offset; + u32 bi_start; + u32 bi_len; }; struct gfs2_rgrpd { @@ -72,14 +72,14 @@ struct gfs2_rgrpd { struct gfs2_glock *rd_gl; /* Glock for this rgrp */ struct gfs2_rindex rd_ri; struct gfs2_rgrp rd_rg; - uint64_t rd_rg_vn; + u64 rd_rg_vn; struct gfs2_bitmap *rd_bits; unsigned int rd_bh_count; struct mutex rd_mutex; - uint32_t rd_free_clone; + u32 rd_free_clone; struct gfs2_log_element rd_le; - uint32_t rd_last_alloc_data; - uint32_t rd_last_alloc_meta; + u32 rd_last_alloc_data; + u32 rd_last_alloc_meta; struct gfs2_sbd *rd_sbd; }; @@ -185,7 +185,7 @@ struct gfs2_glock { char *gl_lvb; atomic_t gl_lvb_count; - uint64_t gl_vn; + u64 gl_vn; unsigned long gl_stamp; void *gl_object; @@ -232,14 +232,14 @@ struct gfs2_inode { unsigned long i_flags; /* GIF_... */ - uint64_t i_vn; + u64 i_vn; struct gfs2_dinode i_di; /* To be replaced by ref to block */ struct gfs2_glock *i_gl; /* Move into i_gh? */ struct gfs2_holder i_iopen_gh; struct gfs2_holder i_gh; /* for prepare/commit_write only */ struct gfs2_alloc i_alloc; - uint64_t i_last_rg_alloc; + u64 i_last_rg_alloc; spinlock_t i_spin; struct rw_semaphore i_rw_mutex; @@ -277,12 +277,12 @@ struct gfs2_file { struct gfs2_revoke { struct gfs2_log_element rv_le; - uint64_t rv_blkno; + u64 rv_blkno; }; struct gfs2_revoke_replay { struct list_head rr_list; - uint64_t rr_blkno; + u64 rr_blkno; unsigned int rr_where; }; @@ -304,11 +304,11 @@ struct gfs2_quota_data { struct list_head qd_list; unsigned int qd_count; - uint32_t qd_id; + u32 qd_id; unsigned long qd_flags; /* QDF_... */ - int64_t qd_change; - int64_t qd_change_sync; + s64 qd_change; + s64 qd_change_sync; unsigned int qd_slot; unsigned int qd_slot_count; @@ -320,7 +320,7 @@ struct gfs2_quota_data { struct gfs2_glock *qd_gl; struct gfs2_quota_lvb qd_qb; - uint64_t qd_sync_gen; + u64 qd_sync_gen; unsigned long qd_last_warn; unsigned long qd_last_touched; }; @@ -358,7 +358,7 @@ struct gfs2_ail { struct list_head ai_ail1_list; struct list_head ai_ail2_list; - uint64_t ai_sync_gen; + u64 ai_sync_gen; }; struct gfs2_jdesc { @@ -466,20 +466,20 @@ struct gfs2_sbd { /* Constants computed on mount */ - uint32_t sd_fsb2bb; - uint32_t sd_fsb2bb_shift; - uint32_t sd_diptrs; /* Number of pointers in a dinode */ - uint32_t sd_inptrs; /* Number of pointers in a indirect block */ - uint32_t sd_jbsize; /* Size of a journaled data block */ - uint32_t sd_hash_bsize; /* sizeof(exhash block) */ - uint32_t sd_hash_bsize_shift; - uint32_t sd_hash_ptrs; /* Number of pointers in a hash block */ - uint32_t sd_qc_per_block; - uint32_t sd_max_dirres; /* Max blocks needed to add a directory entry */ - uint32_t sd_max_height; /* Max height of a file's metadata tree */ - uint64_t sd_heightsize[GFS2_MAX_META_HEIGHT]; - uint32_t sd_max_jheight; /* Max height of journaled file's meta tree */ - uint64_t sd_jheightsize[GFS2_MAX_META_HEIGHT]; + u32 sd_fsb2bb; + u32 sd_fsb2bb_shift; + u32 sd_diptrs; /* Number of pointers in a dinode */ + u32 sd_inptrs; /* Number of pointers in a indirect block */ + u32 sd_jbsize; /* Size of a journaled data block */ + u32 sd_hash_bsize; /* sizeof(exhash block) */ + u32 sd_hash_bsize_shift; + u32 sd_hash_ptrs; /* Number of pointers in a hash block */ + u32 sd_qc_per_block; + u32 sd_max_dirres; /* Max blocks needed to add a directory entry */ + u32 sd_max_height; /* Max height of a file's metadata tree */ + u64 sd_heightsize[GFS2_MAX_META_HEIGHT]; + u32 sd_max_jheight; /* Max height of journaled file's meta tree */ + u64 sd_jheightsize[GFS2_MAX_META_HEIGHT]; struct gfs2_args sd_args; /* Mount arguments */ struct gfs2_tune sd_tune; /* Filesystem tuning structure */ @@ -522,7 +522,7 @@ struct gfs2_sbd { /* Resource group stuff */ - uint64_t sd_rindex_vn; + u64 sd_rindex_vn; spinlock_t sd_rindex_spin; struct mutex sd_rindex_mutex; struct list_head sd_rindex_list; @@ -567,7 +567,7 @@ struct gfs2_sbd { unsigned int sd_quota_chunks; unsigned char **sd_quota_bitmap; - uint64_t sd_quota_sync_gen; + u64 sd_quota_sync_gen; unsigned long sd_quota_sync_time; /* Log stuff */ @@ -595,7 +595,7 @@ struct gfs2_sbd { unsigned int sd_log_blks_free; struct mutex sd_log_reserve_mutex; - uint64_t sd_log_sequence; + u64 sd_log_sequence; unsigned int sd_log_head; unsigned int sd_log_tail; int sd_log_idle; @@ -605,11 +605,11 @@ struct gfs2_sbd { struct list_head sd_log_flush_list; unsigned int sd_log_flush_head; - uint64_t sd_log_flush_wrapped; + u64 sd_log_flush_wrapped; struct list_head sd_ail1_list; struct list_head sd_ail2_list; - uint64_t sd_ail_sync_gen; + u64 sd_ail_sync_gen; /* Replay stuff */ diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 1aaaaa1cc8c32d..f683a400b0068f 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -311,7 +311,7 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff) { struct gfs2_sbd *sdp = ip->i_inode.i_sb->s_fs_info; struct buffer_head *dibh; - uint32_t nlink; + u32 nlink; int error; BUG_ON(ip->i_di.di_nlink != ip->i_inode.i_nlink); @@ -428,7 +428,7 @@ out: return inode; } -static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino) +static int pick_formal_ino_1(struct gfs2_sbd *sdp, u64 *formal_ino) { struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode); struct buffer_head *bh; @@ -469,7 +469,7 @@ static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino) return 1; } -static int pick_formal_ino_2(struct gfs2_sbd *sdp, uint64_t *formal_ino) +static int pick_formal_ino_2(struct gfs2_sbd *sdp, u64 *formal_ino) { struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode); struct gfs2_inode *m_ip = GFS2_I(sdp->sd_inum_inode); @@ -495,13 +495,13 @@ static int pick_formal_ino_2(struct gfs2_sbd *sdp, uint64_t *formal_ino) if (!ir.ir_length) { struct buffer_head *m_bh; - uint64_t x, y; + u64 x, y; error = gfs2_meta_inode_buffer(m_ip, &m_bh); if (error) goto out_brelse; - x = *(uint64_t *)(m_bh->b_data + sizeof(struct gfs2_dinode)); + x = *(u64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)); x = y = be64_to_cpu(x); ir.ir_start = x; ir.ir_length = GFS2_INUM_QUANTUM; @@ -510,7 +510,7 @@ static int pick_formal_ino_2(struct gfs2_sbd *sdp, uint64_t *formal_ino) gfs2_consist_inode(m_ip); x = cpu_to_be64(x); gfs2_trans_add_bh(m_ip->i_gl, m_bh, 1); - *(uint64_t *)(m_bh->b_data + sizeof(struct gfs2_dinode)) = x; + *(u64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)) = x; brelse(m_bh); } @@ -531,7 +531,7 @@ out: return error; } -static int pick_formal_ino(struct gfs2_sbd *sdp, uint64_t *inum) +static int pick_formal_ino(struct gfs2_sbd *sdp, u64 *inum) { int error; @@ -577,9 +577,9 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name, return error; } - if (dip->i_di.di_entries == (uint32_t)-1) + if (dip->i_di.di_entries == (u32)-1) return -EFBIG; - if (S_ISDIR(mode) && dip->i_di.di_nlink == (uint32_t)-1) + if (S_ISDIR(mode) && dip->i_di.di_nlink == (u32)-1) return -EMLINK; return 0; @@ -1131,7 +1131,7 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh) struct gfs2_glock *gl = gh->gh_gl; struct gfs2_sbd *sdp = gl->gl_sbd; struct gfs2_inode *ip = gl->gl_object; - int64_t curtime, quantum = gfs2_tune_get(sdp, gt_atime_quantum); + s64 curtime, quantum = gfs2_tune_get(sdp, gt_atime_quantum); unsigned int state; int flags; int error; diff --git a/fs/gfs2/lm_interface.h b/fs/gfs2/lm_interface.h index 0bf4c276e0fead..e2dfc3da4da963 100644 --- a/fs/gfs2/lm_interface.h +++ b/fs/gfs2/lm_interface.h @@ -160,7 +160,7 @@ typedef void (*lm_callback_t) (lm_fsdata_t *fsdata, unsigned int type, struct lm_lockname { - uint64_t ln_number; + u64 ln_number; unsigned int ln_type; }; diff --git a/fs/gfs2/locking/dlm/lock.c b/fs/gfs2/locking/dlm/lock.c index 1f15b6e8b2cf36..dceea419b94b57 100644 --- a/fs/gfs2/locking/dlm/lock.c +++ b/fs/gfs2/locking/dlm/lock.c @@ -61,7 +61,7 @@ void gdlm_queue_delayed(struct gdlm_lock *lp) /* convert gfs lock-state to dlm lock-mode */ -static int16_t make_mode(int16_t lmstate) +static s16 make_mode(s16 lmstate) { switch (lmstate) { case LM_ST_UNLOCKED: @@ -79,7 +79,7 @@ static int16_t make_mode(int16_t lmstate) /* convert dlm lock-mode to gfs lock-state */ -int16_t gdlm_make_lmstate(int16_t dlmmode) +s16 gdlm_make_lmstate(s16 dlmmode) { switch (dlmmode) { case DLM_LOCK_IV: @@ -101,14 +101,14 @@ int16_t gdlm_make_lmstate(int16_t dlmmode) static void check_cur_state(struct gdlm_lock *lp, unsigned int cur_state) { - int16_t cur = make_mode(cur_state); + s16 cur = make_mode(cur_state); if (lp->cur != DLM_LOCK_IV) gdlm_assert(lp->cur == cur, "%d, %d", lp->cur, cur); } static inline unsigned int make_flags(struct gdlm_lock *lp, unsigned int gfs_flags, - int16_t cur, int16_t req) + s16 cur, s16 req) { unsigned int lkf = 0; diff --git a/fs/gfs2/locking/dlm/lock_dlm.h b/fs/gfs2/locking/dlm/lock_dlm.h index 941063498532ba..c7b6e370258f60 100644 --- a/fs/gfs2/locking/dlm/lock_dlm.h +++ b/fs/gfs2/locking/dlm/lock_dlm.h @@ -56,7 +56,7 @@ enum { }; struct gdlm_ls { - uint32_t id; + u32 id; int jid; int first; int first_done; @@ -77,7 +77,7 @@ struct gdlm_ls { struct list_head delayed; struct list_head submit; struct list_head all_locks; - uint32_t all_locks_count; + u32 all_locks_count; wait_queue_head_t wait_control; struct task_struct *thread1; struct task_struct *thread2; @@ -109,10 +109,10 @@ struct gdlm_lock { char *lvb; struct dlm_lksb lksb; - int16_t cur; - int16_t req; - int16_t prev_req; - uint32_t lkf; /* dlm flags DLM_LKF_ */ + s16 cur; + s16 req; + s16 prev_req; + u32 lkf; /* dlm flags DLM_LKF_ */ unsigned long flags; /* lock_dlm flags LFL_ */ int bast_mode; /* protected by async_lock */ @@ -158,7 +158,7 @@ void gdlm_release_threads(struct gdlm_ls *); /* lock.c */ -int16_t gdlm_make_lmstate(int16_t); +s16 gdlm_make_lmstate(s16); void gdlm_queue_delayed(struct gdlm_lock *); void gdlm_submit_delayed(struct gdlm_ls *); int gdlm_release_all_locks(struct gdlm_ls *); diff --git a/fs/gfs2/locking/dlm/thread.c b/fs/gfs2/locking/dlm/thread.c index a782246d666bb7..d4895ec242f61d 100644 --- a/fs/gfs2/locking/dlm/thread.c +++ b/fs/gfs2/locking/dlm/thread.c @@ -48,7 +48,7 @@ static void process_complete(struct gdlm_lock *lp) { struct gdlm_ls *ls = lp->ls; struct lm_async_cb acb; - int16_t prev_mode = lp->cur; + s16 prev_mode = lp->cur; memset(&acb, 0, sizeof(acb)); diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 45ea3ec6f776e3..5713890128741e 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -62,7 +62,7 @@ unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct, void gfs2_ail1_start(struct gfs2_sbd *sdp, int flags) { struct list_head *head = &sdp->sd_ail1_list; - uint64_t sync_gen; + u64 sync_gen; struct list_head *first, *tmp; struct gfs2_ail *first_ai, *ai; @@ -205,10 +205,10 @@ void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks) up_read(&sdp->sd_log_flush_lock); } -static uint64_t log_bmap(struct gfs2_sbd *sdp, unsigned int lbn) +static u64 log_bmap(struct gfs2_sbd *sdp, unsigned int lbn) { int new = 0; - uint64_t dbn; + u64 dbn; int error; int bdy; @@ -287,7 +287,7 @@ static inline void log_incr_head(struct gfs2_sbd *sdp) struct buffer_head *gfs2_log_get_buf(struct gfs2_sbd *sdp) { - uint64_t blkno = log_bmap(sdp, sdp->sd_log_flush_head); + u64 blkno = log_bmap(sdp, sdp->sd_log_flush_head); struct gfs2_log_buf *lb; struct buffer_head *bh; @@ -317,7 +317,7 @@ struct buffer_head *gfs2_log_get_buf(struct gfs2_sbd *sdp) struct buffer_head *gfs2_log_fake_buf(struct gfs2_sbd *sdp, struct buffer_head *real) { - uint64_t blkno = log_bmap(sdp, sdp->sd_log_flush_head); + u64 blkno = log_bmap(sdp, sdp->sd_log_flush_head); struct gfs2_log_buf *lb; struct buffer_head *bh; @@ -361,13 +361,13 @@ static void log_pull_tail(struct gfs2_sbd *sdp, unsigned int new_tail, int pull) * Returns: the initialized log buffer descriptor */ -static void log_write_header(struct gfs2_sbd *sdp, uint32_t flags, int pull) +static void log_write_header(struct gfs2_sbd *sdp, u32 flags, int pull) { - uint64_t blkno = log_bmap(sdp, sdp->sd_log_flush_head); + u64 blkno = log_bmap(sdp, sdp->sd_log_flush_head); struct buffer_head *bh; struct gfs2_log_header *lh; unsigned int tail; - uint32_t hash; + u32 hash; /* printk(KERN_INFO "log write header start (flags=%08x, pull=%d)\n", flags, pull); */ @@ -523,7 +523,7 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr) reserved += sdp->sd_log_commited_buf; if (sdp->sd_log_commited_revoke) reserved += gfs2_struct2blk(sdp, sdp->sd_log_commited_revoke, - sizeof(uint64_t)); + sizeof(u64)); if (reserved) reserved++; diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index e2c2582c8f6e04..456d6ad1049d51 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -202,7 +202,7 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, struct gfs2_glock *gl = ip->i_gl; unsigned int blks = be32_to_cpu(ld->ld_data1); struct buffer_head *bh_log, *bh_ip; - uint64_t blkno; + u64 blkno; int error = 0; if (pass != 1 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_METADATA) @@ -294,7 +294,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) ld->ld_header.mh_format = cpu_to_be32(GFS2_FORMAT_LD); ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_REVOKE); ld->ld_length = cpu_to_be32(gfs2_struct2blk(sdp, sdp->sd_log_num_revoke, - sizeof(uint64_t))); + sizeof(u64))); ld->ld_data1 = cpu_to_be32(sdp->sd_log_num_revoke); ld->ld_data2 = cpu_to_be32(0); memset(ld->ld_reserved, 0, sizeof(ld->ld_reserved)); @@ -305,7 +305,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) list_del_init(&rv->rv_le.le_list); sdp->sd_log_num_revoke--; - if (offset + sizeof(uint64_t) > sdp->sd_sb.sb_bsize) { + if (offset + sizeof(u64) > sdp->sd_sb.sb_bsize) { set_buffer_dirty(bh); ll_rw_block(WRITE, 1, &bh); @@ -320,7 +320,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp) *(__be64 *)(bh->b_data + offset) = cpu_to_be64(rv->rv_blkno); kfree(rv); - offset += sizeof(uint64_t); + offset += sizeof(u64); } gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke); @@ -349,7 +349,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, unsigned int revokes = be32_to_cpu(ld->ld_data1); struct buffer_head *bh; unsigned int offset; - uint64_t blkno; + u64 blkno; int first = 1; int error; @@ -366,7 +366,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, if (!first) gfs2_metatype_check(sdp, bh, GFS2_METATYPE_LB); - while (offset + sizeof(uint64_t) <= sdp->sd_sb.sb_bsize) { + while (offset + sizeof(u64) <= sdp->sd_sb.sb_bsize) { blkno = be64_to_cpu(*(__be64 *)(bh->b_data + offset)); error = gfs2_revoke_add(sdp, blkno, start); @@ -377,7 +377,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, if (!--revokes) break; - offset += sizeof(uint64_t); + offset += sizeof(u64); } brelse(bh); @@ -677,8 +677,8 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start, struct gfs2_glock *gl = ip->i_gl; unsigned int blks = be32_to_cpu(ld->ld_data1); struct buffer_head *bh_log, *bh_ip; - uint64_t blkno; - uint64_t esc; + u64 blkno; + u64 esc; int error = 0; if (pass != 1 || be32_to_cpu(ld->ld_type) != GFS2_LOG_DESC_JDATA) diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 3f6da00e2f5964..5b10379c20ebb5 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -213,7 +213,7 @@ void gfs2_ail_empty_gl(struct gfs2_glock *gl) struct list_head *head = &gl->gl_ail_list; struct gfs2_bufdata *bd; struct buffer_head *bh; - uint64_t blkno; + u64 blkno; int error; blocks = atomic_read(&gl->gl_ail_count); @@ -303,7 +303,7 @@ void gfs2_meta_sync(struct gfs2_glock *gl, int flags) */ static struct buffer_head *getbuf(struct gfs2_sbd *sdp, struct inode *aspace, - uint64_t blkno, int create) + u64 blkno, int create) { struct page *page; struct buffer_head *bh; @@ -366,7 +366,7 @@ static void meta_prep_new(struct buffer_head *bh) * Returns: The buffer */ -struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, uint64_t blkno) +struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno) { struct buffer_head *bh; bh = getbuf(gl->gl_sbd, gl->gl_aspace, blkno, CREATE); @@ -384,7 +384,7 @@ struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, uint64_t blkno) * Returns: errno */ -int gfs2_meta_read(struct gfs2_glock *gl, uint64_t blkno, int flags, +int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags, struct buffer_head **bhp) { int error; @@ -549,7 +549,7 @@ void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh, * */ -void gfs2_meta_wipe(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen) +void gfs2_meta_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct inode *aspace = ip->i_gl->gl_aspace; @@ -573,7 +573,7 @@ void gfs2_meta_wipe(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen) if (bd) { gfs2_log_lock(sdp); if (bd->bd_ail) { - uint64_t blkno = bh->b_blocknr; + u64 blkno = bh->b_blocknr; bd->bd_ail = NULL; list_del(&bd->bd_ail_st_list); list_del(&bd->bd_ail_gl_list); @@ -637,7 +637,7 @@ void gfs2_meta_cache_flush(struct gfs2_inode *ip) * Returns: errno */ -int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, uint64_t num, +int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, u64 num, int new, struct buffer_head **bhp) { struct buffer_head *bh, **bh_slot = ip->i_cache + height; @@ -711,12 +711,12 @@ int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, uint64_t num, * */ -void gfs2_meta_ra(struct gfs2_glock *gl, uint64_t dblock, uint32_t extlen) +void gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen) { struct gfs2_sbd *sdp = gl->gl_sbd; struct inode *aspace = gl->gl_aspace; struct buffer_head *first_bh, *bh; - uint32_t max_ra = gfs2_tune_get(sdp, gt_max_readahead) >> + u32 max_ra = gfs2_tune_get(sdp, gt_max_readahead) >> sdp->sd_sb.sb_bsize_shift; int error; diff --git a/fs/gfs2/meta_io.h b/fs/gfs2/meta_io.h index 4ddc936aae16d1..9a9acc94029282 100644 --- a/fs/gfs2/meta_io.h +++ b/fs/gfs2/meta_io.h @@ -44,8 +44,8 @@ void gfs2_ail_empty_gl(struct gfs2_glock *gl); void gfs2_meta_inval(struct gfs2_glock *gl); void gfs2_meta_sync(struct gfs2_glock *gl, int flags); -struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, uint64_t blkno); -int gfs2_meta_read(struct gfs2_glock *gl, uint64_t blkno, +struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno); +int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags, struct buffer_head **bhp); int gfs2_meta_reread(struct gfs2_sbd *sdp, struct buffer_head *bh, int flags); @@ -55,10 +55,10 @@ void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh); void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh, struct gfs2_ail *ai); -void gfs2_meta_wipe(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen); +void gfs2_meta_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen); void gfs2_meta_cache_flush(struct gfs2_inode *ip); -int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, uint64_t num, +int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, u64 num, int new, struct buffer_head **bhp); static inline int gfs2_meta_inode_buffer(struct gfs2_inode *ip, @@ -67,7 +67,7 @@ static inline int gfs2_meta_inode_buffer(struct gfs2_inode *ip, return gfs2_meta_indirect_buffer(ip, 0, ip->i_num.no_addr, 0, bhp); } -void gfs2_meta_ra(struct gfs2_glock *gl, uint64_t dblock, uint32_t extlen); +void gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen); void gfs2_meta_syncfs(struct gfs2_sbd *sdp); #endif /* __DIO_DOT_H__ */ diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 21ae9e4f0f6c00..ae9c46e75392b3 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -66,7 +66,7 @@ int gfs2_get_block(struct inode *inode, sector_t lblock, struct buffer_head *bh_result, int create) { int new = create; - uint64_t dblock; + u64 dblock; int error; int boundary; @@ -100,7 +100,7 @@ static int get_block_noalloc(struct inode *inode, sector_t lblock, struct buffer_head *bh_result, int create) { int new = 0; - uint64_t dblock; + u64 dblock; int error; int boundary; @@ -510,10 +510,10 @@ static int gfs2_commit_write(struct file *file, struct page *page, gfs2_trans_add_bh(ip->i_gl, dibh, 1); if (gfs2_is_stuffed(ip)) { - uint64_t file_size; + u64 file_size; void *kaddr; - file_size = ((uint64_t)page->index << PAGE_CACHE_SHIFT) + to; + file_size = ((u64)page->index << PAGE_CACHE_SHIFT) + to; kaddr = kmap_atomic(page, KM_USER0); memcpy(dibh->b_data + sizeof(struct gfs2_dinode) + from, diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index c94cbc8b6ef60a..cf826893dd5f88 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c @@ -46,15 +46,15 @@ static struct dentry *gfs2_decode_fh(struct super_block *sb, switch (fh_type) { case 10: - parent.no_formal_ino = ((uint64_t)be32_to_cpu(fh[4])) << 32; + parent.no_formal_ino = ((u64)be32_to_cpu(fh[4])) << 32; parent.no_formal_ino |= be32_to_cpu(fh[5]); - parent.no_addr = ((uint64_t)be32_to_cpu(fh[6])) << 32; + parent.no_addr = ((u64)be32_to_cpu(fh[6])) << 32; parent.no_addr |= be32_to_cpu(fh[7]); fh_obj.imode = be32_to_cpu(fh[8]); case 4: - this->no_formal_ino = ((uint64_t)be32_to_cpu(fh[0])) << 32; + this->no_formal_ino = ((u64)be32_to_cpu(fh[0])) << 32; this->no_formal_ino |= be32_to_cpu(fh[1]); - this->no_addr = ((uint64_t)be32_to_cpu(fh[2])) << 32; + this->no_addr = ((u64)be32_to_cpu(fh[2])) << 32; this->no_addr |= be32_to_cpu(fh[3]); break; default: @@ -118,7 +118,7 @@ struct get_name_filldir { }; static int get_name_filldir(void *opaque, const char *name, unsigned int length, - uint64_t offset, struct gfs2_inum *inum, + u64 offset, struct gfs2_inum *inum, unsigned int type) { struct get_name_filldir *gnfd = (struct get_name_filldir *)opaque; @@ -140,7 +140,7 @@ static int gfs2_get_name(struct dentry *parent, char *name, struct gfs2_inode *dip, *ip; struct get_name_filldir gnfd; struct gfs2_holder gh; - uint64_t offset = 0; + u64 offset = 0; int error; if (!dir) diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index 53ce7816dc1899..f5ddd496d3ecfc 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c @@ -47,7 +47,7 @@ struct filldir_bad_entry { char *fbe_name; unsigned int fbe_length; - uint64_t fbe_offset; + u64 fbe_offset; struct gfs2_inum fbe_inum; unsigned int fbe_type; }; @@ -161,7 +161,7 @@ static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin) */ static int filldir_reg_func(void *opaque, const char *name, unsigned int length, - uint64_t offset, struct gfs2_inum *inum, + u64 offset, struct gfs2_inum *inum, unsigned int type) { struct filldir_reg *fdr = (struct filldir_reg *)opaque; @@ -200,7 +200,7 @@ static int readdir_reg(struct file *file, void *dirent, filldir_t filldir) struct gfs2_inode *dip = GFS2_I(dir); struct filldir_reg fdr; struct gfs2_holder d_gh; - uint64_t offset = file->f_pos; + u64 offset = file->f_pos; int error; fdr.fdr_sbd = GFS2_SB(dir); @@ -239,7 +239,7 @@ static int readdir_reg(struct file *file, void *dirent, filldir_t filldir) */ static int filldir_bad_func(void *opaque, const char *name, unsigned int length, - uint64_t offset, struct gfs2_inum *inum, + u64 offset, struct gfs2_inum *inum, unsigned int type) { struct filldir_bad *fdb = (struct filldir_bad *)opaque; @@ -293,7 +293,7 @@ static int readdir_bad(struct file *file, void *dirent, filldir_t filldir) unsigned int entries, size; struct filldir_bad *fdb; struct gfs2_holder d_gh; - uint64_t offset = file->f_pos; + u64 offset = file->f_pos; unsigned int x; struct filldir_bad_entry *fbe; int error; diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index bd9b9957f707ba..c680f050e17f9d 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -172,7 +172,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, if (!dip->i_di.di_nlink) goto out_gunlock; error = -EFBIG; - if (dip->i_di.di_entries == (uint32_t)-1) + if (dip->i_di.di_entries == (u32)-1) goto out_gunlock; error = -EPERM; if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) @@ -181,7 +181,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, if (!ip->i_di.di_nlink) goto out_gunlock; error = -EMLINK; - if (ip->i_di.di_nlink == (uint32_t)-1) + if (ip->i_di.di_nlink == (u32)-1) goto out_gunlock; alloc_required = error = gfs2_diradd_alloc_required(dir, &dentry->d_name); @@ -509,7 +509,7 @@ static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, struct gfs2_holder ghs[2]; struct inode *inode; struct buffer_head *dibh; - uint32_t major = 0, minor = 0; + u32 major = 0, minor = 0; int error; switch (mode & S_IFMT) { @@ -670,12 +670,12 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, error = -EINVAL; goto out_gunlock; } - if (ndip->i_di.di_entries == (uint32_t)-1) { + if (ndip->i_di.di_entries == (u32)-1) { error = -EFBIG; goto out_gunlock; } if (S_ISDIR(ip->i_di.di_mode) && - ndip->i_di.di_nlink == (uint32_t)-1) { + ndip->i_di.di_nlink == (u32)-1) { error = -EMLINK; goto out_gunlock; } @@ -911,7 +911,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr) struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_sbd *sdp = GFS2_SB(inode); struct buffer_head *dibh; - uint32_t ouid, ogid, nuid, ngid; + u32 ouid, ogid, nuid, ngid; int error; ouid = ip->i_di.di_uid; diff --git a/fs/gfs2/ops_vm.c b/fs/gfs2/ops_vm.c index 32ec8574ac8e34..3b3463144126fd 100644 --- a/fs/gfs2/ops_vm.c +++ b/fs/gfs2/ops_vm.c @@ -62,7 +62,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); unsigned long index = page->index; - uint64_t lblock = index << (PAGE_CACHE_SHIFT - + u64 lblock = index << (PAGE_CACHE_SHIFT - sdp->sd_sb.sb_bsize_shift); unsigned int blocks = PAGE_CACHE_SIZE >> sdp->sd_sb.sb_bsize_shift; struct gfs2_alloc *al; @@ -101,7 +101,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page) } for (x = 0; x < blocks; ) { - uint64_t dblock; + u64 dblock; unsigned int extlen; int new = 1; diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 572b92eac36712..f5830befc307ea 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -65,17 +65,17 @@ #define QUOTA_USER 1 #define QUOTA_GROUP 0 -static uint64_t qd2offset(struct gfs2_quota_data *qd) +static u64 qd2offset(struct gfs2_quota_data *qd) { - uint64_t offset; + u64 offset; - offset = 2 * (uint64_t)qd->qd_id + !test_bit(QDF_USER, &qd->qd_flags); + offset = 2 * (u64)qd->qd_id + !test_bit(QDF_USER, &qd->qd_flags); offset *= sizeof(struct gfs2_quota); return offset; } -static int qd_alloc(struct gfs2_sbd *sdp, int user, uint32_t id, +static int qd_alloc(struct gfs2_sbd *sdp, int user, u32 id, struct gfs2_quota_data **qdp) { struct gfs2_quota_data *qd; @@ -91,7 +91,7 @@ static int qd_alloc(struct gfs2_sbd *sdp, int user, uint32_t id, set_bit(QDF_USER, &qd->qd_flags); qd->qd_slot = -1; - error = gfs2_glock_get(sdp, 2 * (uint64_t)id + !user, + error = gfs2_glock_get(sdp, 2 * (u64)id + !user, &gfs2_quota_glops, CREATE, &qd->qd_gl); if (error) goto fail; @@ -110,7 +110,7 @@ fail: return error; } -static int qd_get(struct gfs2_sbd *sdp, int user, uint32_t id, int create, +static int qd_get(struct gfs2_sbd *sdp, int user, u32 id, int create, struct gfs2_quota_data **qdp) { struct gfs2_quota_data *qd = NULL, *new_qd = NULL; @@ -248,7 +248,7 @@ static int bh_get(struct gfs2_quota_data *qd) struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode); unsigned int block, offset; - uint64_t dblock; + u64 dblock; int new = 0; struct buffer_head *bh; int error; @@ -405,7 +405,7 @@ static void qd_unlock(struct gfs2_quota_data *qd) qd_put(qd); } -static int qdsb_get(struct gfs2_sbd *sdp, int user, uint32_t id, int create, +static int qdsb_get(struct gfs2_sbd *sdp, int user, u32 id, int create, struct gfs2_quota_data **qdp) { int error; @@ -438,7 +438,7 @@ static void qdsb_put(struct gfs2_quota_data *qd) qd_put(qd); } -int gfs2_quota_hold(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) +int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; @@ -523,12 +523,12 @@ static int sort_qd(const void *a, const void *b) return ret; } -static void do_qc(struct gfs2_quota_data *qd, int64_t change) +static void do_qc(struct gfs2_quota_data *qd, s64 change) { struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode); struct gfs2_quota_change *qc = qd->qd_bh_qc; - int64_t x; + s64 x; mutex_lock(&sdp->sd_quota_mutex); gfs2_trans_add_bh(ip->i_gl, qd->qd_bh, 1); @@ -571,7 +571,7 @@ static void do_qc(struct gfs2_quota_data *qd, int64_t change) * in turn mostly borrowed from ext3 */ static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc, - int64_t change, struct gfs2_quota_data *qd) + s64 change, struct gfs2_quota_data *qd) { struct inode *inode = &ip->i_inode; struct address_space *mapping = inode->i_mapping; @@ -811,7 +811,7 @@ fail: return error; } -int gfs2_quota_lock(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) +int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; @@ -848,7 +848,7 @@ static int need_sync(struct gfs2_quota_data *qd) { struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; struct gfs2_tune *gt = &sdp->sd_tune; - int64_t value; + s64 value; unsigned int num, den; int do_sync = 1; @@ -873,7 +873,7 @@ static int need_sync(struct gfs2_quota_data *qd) value *= gfs2_jindex_size(sdp) * num; do_div(value, den); value += (s64)be64_to_cpu(qd->qd_qb.qb_value); - if (value < (int64_t)be64_to_cpu(qd->qd_qb.qb_limit)) + if (value < (s64)be64_to_cpu(qd->qd_qb.qb_limit)) do_sync = 0; } @@ -927,12 +927,12 @@ static int print_message(struct gfs2_quota_data *qd, char *type) return 0; } -int gfs2_quota_check(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) +int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; struct gfs2_quota_data *qd; - int64_t value; + s64 value; unsigned int x; int error = 0; @@ -954,12 +954,12 @@ int gfs2_quota_check(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) value += qd->qd_change; spin_unlock(&sdp->sd_quota_spin); - if (be64_to_cpu(qd->qd_qb.qb_limit) && (int64_t)be64_to_cpu(qd->qd_qb.qb_limit) < value) { + if (be64_to_cpu(qd->qd_qb.qb_limit) && (s64)be64_to_cpu(qd->qd_qb.qb_limit) < value) { print_message(qd, "exceeded"); error = -EDQUOT; break; } else if (be64_to_cpu(qd->qd_qb.qb_warn) && - (int64_t)be64_to_cpu(qd->qd_qb.qb_warn) < value && + (s64)be64_to_cpu(qd->qd_qb.qb_warn) < value && time_after_eq(jiffies, qd->qd_last_warn + gfs2_tune_get(sdp, gt_quota_warn_period) * HZ)) { @@ -971,8 +971,8 @@ int gfs2_quota_check(struct gfs2_inode *ip, uint32_t uid, uint32_t gid) return error; } -void gfs2_quota_change(struct gfs2_inode *ip, int64_t change, - uint32_t uid, uint32_t gid) +void gfs2_quota_change(struct gfs2_inode *ip, s64 change, + u32 uid, u32 gid) { struct gfs2_alloc *al = &ip->i_alloc; struct gfs2_quota_data *qd; @@ -1038,7 +1038,7 @@ int gfs2_quota_sync(struct gfs2_sbd *sdp) return error; } -int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, uint32_t id) +int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id) { struct gfs2_quota_data *qd; struct gfs2_holder q_gh; @@ -1058,7 +1058,7 @@ int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, uint32_t id) } #if 0 -int gfs2_quota_read(struct gfs2_sbd *sdp, int user, uint32_t id, +int gfs2_quota_read(struct gfs2_sbd *sdp, int user, u32 id, struct gfs2_quota *q) { struct gfs2_quota_data *qd; @@ -1100,8 +1100,8 @@ int gfs2_quota_init(struct gfs2_sbd *sdp) unsigned int blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; unsigned int x, slot = 0; unsigned int found = 0; - uint64_t dblock; - uint32_t extlen = 0; + u64 dblock; + u32 extlen = 0; int error; if (!ip->i_di.di_size || diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h index 6702a56d49b539..d93c61c99365ef 100644 --- a/fs/gfs2/quota.h +++ b/fs/gfs2/quota.h @@ -10,20 +10,20 @@ #ifndef __QUOTA_DOT_H__ #define __QUOTA_DOT_H__ -#define NO_QUOTA_CHANGE ((uint32_t)-1) +#define NO_QUOTA_CHANGE ((u32)-1) -int gfs2_quota_hold(struct gfs2_inode *ip, uint32_t uid, uint32_t gid); +int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid); void gfs2_quota_unhold(struct gfs2_inode *ip); -int gfs2_quota_lock(struct gfs2_inode *ip, uint32_t uid, uint32_t gid); +int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid); void gfs2_quota_unlock(struct gfs2_inode *ip); -int gfs2_quota_check(struct gfs2_inode *ip, uint32_t uid, uint32_t gid); -void gfs2_quota_change(struct gfs2_inode *ip, int64_t change, - uint32_t uid, uint32_t gid); +int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid); +void gfs2_quota_change(struct gfs2_inode *ip, s64 change, + u32 uid, u32 gid); int gfs2_quota_sync(struct gfs2_sbd *sdp); -int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, uint32_t id); +int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id); int gfs2_quota_init(struct gfs2_sbd *sdp); void gfs2_quota_scan(struct gfs2_sbd *sdp); diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index acafe4b4d6f064..ab55191926c3af 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -35,8 +35,8 @@ int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk, struct gfs2_inode *ip = GFS2_I(jd->jd_inode); struct gfs2_glock *gl = ip->i_gl; int new = 0; - uint64_t dblock; - uint32_t extlen; + u64 dblock; + u32 extlen; int error; error = gfs2_extent_map(&ip->i_inode, blk, &new, &dblock, &extlen); @@ -53,7 +53,7 @@ int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk, return error; } -int gfs2_revoke_add(struct gfs2_sbd *sdp, uint64_t blkno, unsigned int where) +int gfs2_revoke_add(struct gfs2_sbd *sdp, u64 blkno, unsigned int where) { struct list_head *head = &sdp->sd_revoke_list; struct gfs2_revoke_replay *rr; @@ -82,7 +82,7 @@ int gfs2_revoke_add(struct gfs2_sbd *sdp, uint64_t blkno, unsigned int where) return 1; } -int gfs2_revoke_check(struct gfs2_sbd *sdp, uint64_t blkno, unsigned int where) +int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where) { struct gfs2_revoke_replay *rr; int wrap, a, b, revoke; @@ -137,7 +137,7 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk, { struct buffer_head *bh; struct gfs2_log_header lh; - uint32_t hash; + u32 hash; int error; error = gfs2_replay_read_block(jd, blk, &bh); @@ -249,7 +249,7 @@ static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head) int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header *head) { struct gfs2_log_header lh_1, lh_m; - uint32_t blk_1, blk_2, blk_m; + u32 blk_1, blk_2, blk_m; int error; blk_1 = 0; @@ -370,9 +370,9 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head) struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); unsigned int lblock; int new = 0; - uint64_t dblock; + u64 dblock; struct gfs2_log_header *lh; - uint32_t hash; + u32 hash; struct buffer_head *bh; int error; int boundary; diff --git a/fs/gfs2/recovery.h b/fs/gfs2/recovery.h index bed1a7857f6e47..1b35516b7591eb 100644 --- a/fs/gfs2/recovery.h +++ b/fs/gfs2/recovery.h @@ -19,8 +19,8 @@ static inline void gfs2_replay_incr_blk(struct gfs2_sbd *sdp, unsigned int *blk) int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk, struct buffer_head **bh); -int gfs2_revoke_add(struct gfs2_sbd *sdp, uint64_t blkno, unsigned int where); -int gfs2_revoke_check(struct gfs2_sbd *sdp, uint64_t blkno, unsigned int where); +int gfs2_revoke_add(struct gfs2_sbd *sdp, u64 blkno, unsigned int where); +int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where); void gfs2_revoke_clean(struct gfs2_sbd *sdp); int gfs2_find_jhead(struct gfs2_jdesc *jd, diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 62d0a84df98272..af49c8b82ffb87 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -60,7 +60,7 @@ static const char valid_change[16] = { */ static void gfs2_setbit(struct gfs2_rgrpd *rgd, unsigned char *buffer, - unsigned int buflen, uint32_t block, + unsigned int buflen, u32 block, unsigned char new_state) { unsigned char *byte, *end, cur_state; @@ -90,7 +90,7 @@ static void gfs2_setbit(struct gfs2_rgrpd *rgd, unsigned char *buffer, */ static unsigned char gfs2_testbit(struct gfs2_rgrpd *rgd, unsigned char *buffer, - unsigned int buflen, uint32_t block) + unsigned int buflen, u32 block) { unsigned char *byte, *end, cur_state; unsigned int bit; @@ -122,12 +122,12 @@ static unsigned char gfs2_testbit(struct gfs2_rgrpd *rgd, unsigned char *buffer, * Return: the block number (bitmap buffer scope) that was found */ -static uint32_t gfs2_bitfit(struct gfs2_rgrpd *rgd, unsigned char *buffer, - unsigned int buflen, uint32_t goal, +static u32 gfs2_bitfit(struct gfs2_rgrpd *rgd, unsigned char *buffer, + unsigned int buflen, u32 goal, unsigned char old_state) { unsigned char *byte, *end, alloc; - uint32_t blk = goal; + u32 blk = goal; unsigned int bit; byte = buffer + (goal / GFS2_NBBY); @@ -169,7 +169,7 @@ static uint32_t gfs2_bitfit(struct gfs2_rgrpd *rgd, unsigned char *buffer, * Returns: The number of bits */ -static uint32_t gfs2_bitcount(struct gfs2_rgrpd *rgd, unsigned char *buffer, +static u32 gfs2_bitcount(struct gfs2_rgrpd *rgd, unsigned char *buffer, unsigned int buflen, unsigned char state) { unsigned char *byte = buffer; @@ -177,7 +177,7 @@ static uint32_t gfs2_bitcount(struct gfs2_rgrpd *rgd, unsigned char *buffer, unsigned char state1 = state << 2; unsigned char state2 = state << 4; unsigned char state3 = state << 6; - uint32_t count = 0; + u32 count = 0; for (; byte < end; byte++) { if (((*byte) & 0x03) == state) @@ -204,11 +204,11 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) { struct gfs2_sbd *sdp = rgd->rd_sbd; struct gfs2_bitmap *bi = NULL; - uint32_t length = rgd->rd_ri.ri_length; - uint32_t count[4], tmp; + u32 length = rgd->rd_ri.ri_length; + u32 count[4], tmp; int buf, x; - memset(count, 0, 4 * sizeof(uint32_t)); + memset(count, 0, 4 * sizeof(u32)); /* Count # blocks in each of 4 possible allocation states */ for (buf = 0; buf < length; buf++) { @@ -253,10 +253,10 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) } -static inline int rgrp_contains_block(struct gfs2_rindex *ri, uint64_t block) +static inline int rgrp_contains_block(struct gfs2_rindex *ri, u64 block) { - uint64_t first = ri->ri_data0; - uint64_t last = first + ri->ri_data; + u64 first = ri->ri_data0; + u64 last = first + ri->ri_data; return !!(first <= block && block < last); } @@ -268,7 +268,7 @@ static inline int rgrp_contains_block(struct gfs2_rindex *ri, uint64_t block) * Returns: The resource group, or NULL if not found */ -struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, uint64_t blk) +struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk) { struct gfs2_rgrpd *rgd; @@ -367,8 +367,8 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) { struct gfs2_sbd *sdp = rgd->rd_sbd; struct gfs2_bitmap *bi; - uint32_t length = rgd->rd_ri.ri_length; /* # blocks in hdr & bitmap */ - uint32_t bytes_left, bytes; + u32 length = rgd->rd_ri.ri_length; /* # blocks in hdr & bitmap */ + u32 bytes_left, bytes; int x; if (!length) @@ -444,7 +444,7 @@ static int gfs2_ri_update(struct gfs2_inode *ip) struct gfs2_rgrpd *rgd; char buf[sizeof(struct gfs2_rindex)]; struct file_ra_state ra_state; - uint64_t junk = ip->i_di.di_size; + u64 junk = ip->i_di.di_size; int error; if (do_div(junk, sizeof(struct gfs2_rindex))) { @@ -741,7 +741,7 @@ static int try_rgrp_fit(struct gfs2_rgrpd *rgd, struct gfs2_alloc *al) */ static struct gfs2_rgrpd *recent_rgrp_first(struct gfs2_sbd *sdp, - uint64_t rglast) + u64 rglast) { struct gfs2_rgrpd *rgd = NULL; @@ -1037,10 +1037,10 @@ void gfs2_inplace_release(struct gfs2_inode *ip) * Returns: The block type (GFS2_BLKST_*) */ -unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, uint64_t block) +unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, u64 block) { struct gfs2_bitmap *bi = NULL; - uint32_t length, rgrp_block, buf_block; + u32 length, rgrp_block, buf_block; unsigned int buf; unsigned char type; @@ -1083,12 +1083,12 @@ unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, uint64_t block) * Returns: the block number allocated */ -static uint32_t rgblk_search(struct gfs2_rgrpd *rgd, uint32_t goal, +static u32 rgblk_search(struct gfs2_rgrpd *rgd, u32 goal, unsigned char old_state, unsigned char new_state) { struct gfs2_bitmap *bi = NULL; - uint32_t length = rgd->rd_ri.ri_length; - uint32_t blk = 0; + u32 length = rgd->rd_ri.ri_length; + u32 blk = 0; unsigned int buf, x; /* Find bitmap block that contains bits for goal block */ @@ -1148,12 +1148,12 @@ static uint32_t rgblk_search(struct gfs2_rgrpd *rgd, uint32_t goal, * Returns: Resource group containing the block(s) */ -static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, uint64_t bstart, - uint32_t blen, unsigned char new_state) +static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart, + u32 blen, unsigned char new_state) { struct gfs2_rgrpd *rgd; struct gfs2_bitmap *bi = NULL; - uint32_t length, rgrp_blk, buf_blk; + u32 length, rgrp_blk, buf_blk; unsigned int buf; rgd = gfs2_blk2rgrpd(sdp, bstart); @@ -1206,8 +1206,8 @@ u64 gfs2_alloc_data(struct gfs2_inode *ip) struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; struct gfs2_rgrpd *rgd = al->al_rgd; - uint32_t goal, blk; - uint64_t block; + u32 goal, blk; + u64 block; if (rgrp_contains_block(&rgd->rd_ri, ip->i_di.di_goal_data)) goal = ip->i_di.di_goal_data - rgd->rd_ri.ri_data0; @@ -1250,8 +1250,8 @@ u64 gfs2_alloc_meta(struct gfs2_inode *ip) struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al = &ip->i_alloc; struct gfs2_rgrpd *rgd = al->al_rgd; - uint32_t goal, blk; - uint64_t block; + u32 goal, blk; + u64 block; if (rgrp_contains_block(&rgd->rd_ri, ip->i_di.di_goal_meta)) goal = ip->i_di.di_goal_meta - rgd->rd_ri.ri_data0; @@ -1332,7 +1332,7 @@ u64 gfs2_alloc_di(struct gfs2_inode *dip, u64 *generation) * */ -void gfs2_free_data(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen) +void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_rgrpd *rgd; @@ -1349,7 +1349,7 @@ void gfs2_free_data(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen) gfs2_trans_add_rg(rgd); gfs2_statfs_change(sdp, 0, +blen, 0); - gfs2_quota_change(ip, -(int64_t)blen, + gfs2_quota_change(ip, -(s64)blen, ip->i_di.di_uid, ip->i_di.di_gid); } @@ -1361,7 +1361,7 @@ void gfs2_free_data(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen) * */ -void gfs2_free_meta(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen) +void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_rgrpd *rgd; @@ -1378,7 +1378,7 @@ void gfs2_free_meta(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen) gfs2_trans_add_rg(rgd); gfs2_statfs_change(sdp, 0, +blen, 0); - gfs2_quota_change(ip, -(int64_t)blen, ip->i_di.di_uid, ip->i_di.di_gid); + gfs2_quota_change(ip, -(s64)blen, ip->i_di.di_uid, ip->i_di.di_gid); gfs2_meta_wipe(ip, bstart, blen); } @@ -1397,7 +1397,7 @@ void gfs2_unlink_di(struct inode *inode) gfs2_trans_add_rg(rgd); } -static void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, uint64_t blkno) +static void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, u64 blkno) { struct gfs2_sbd *sdp = rgd->rd_sbd; struct gfs2_rgrpd *tmp_rgd; @@ -1440,7 +1440,7 @@ void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip) */ void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist, - uint64_t block) + u64 block) { struct gfs2_rgrpd *rgd; struct gfs2_rgrpd **tmp; diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h index f94761bf34605c..3d6ae37e85df26 100644 --- a/fs/gfs2/rgrp.h +++ b/fs/gfs2/rgrp.h @@ -12,7 +12,7 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd); -struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, uint64_t blk); +struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk); struct gfs2_rgrpd *gfs2_rgrpd_get_first(struct gfs2_sbd *sdp); struct gfs2_rgrpd *gfs2_rgrpd_get_next(struct gfs2_rgrpd *rgd); @@ -35,14 +35,14 @@ gfs2_inplace_reserve_i((ip), __FILE__, __LINE__) void gfs2_inplace_release(struct gfs2_inode *ip); -unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, uint64_t block); +unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, u64 block); u64 gfs2_alloc_data(struct gfs2_inode *ip); u64 gfs2_alloc_meta(struct gfs2_inode *ip); u64 gfs2_alloc_di(struct gfs2_inode *ip, u64 *generation); -void gfs2_free_data(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen); -void gfs2_free_meta(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen); +void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen); +void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen); void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip); void gfs2_unlink_di(struct inode *inode); @@ -54,7 +54,7 @@ struct gfs2_rgrp_list { }; void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist, - uint64_t block); + u64 block); void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state, int flags); void gfs2_rlist_free(struct gfs2_rgrp_list *rlist); diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 520266c2044b28..f1d07d987c7bfd 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -33,11 +33,11 @@ #include "trans.h" #include "util.h" -static const uint32_t gfs2_old_fs_formats[] = { +static const u32 gfs2_old_fs_formats[] = { 0 }; -static const uint32_t gfs2_old_multihost_formats[] = { +static const u32 gfs2_old_multihost_formats[] = { 0 }; @@ -225,8 +225,8 @@ static struct page *gfs2_read_super(struct super_block *sb, sector_t sector) int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) { - uint32_t hash_blocks, ind_blocks, leaf_blocks; - uint32_t tmp_blocks; + u32 hash_blocks, ind_blocks, leaf_blocks; + u32 tmp_blocks; unsigned int x; int error; struct page *page; @@ -251,20 +251,20 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) GFS2_BASIC_BLOCK_SHIFT; sdp->sd_fsb2bb = 1 << sdp->sd_fsb2bb_shift; sdp->sd_diptrs = (sdp->sd_sb.sb_bsize - - sizeof(struct gfs2_dinode)) / sizeof(uint64_t); + sizeof(struct gfs2_dinode)) / sizeof(u64); sdp->sd_inptrs = (sdp->sd_sb.sb_bsize - - sizeof(struct gfs2_meta_header)) / sizeof(uint64_t); + sizeof(struct gfs2_meta_header)) / sizeof(u64); sdp->sd_jbsize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header); sdp->sd_hash_bsize = sdp->sd_sb.sb_bsize / 2; sdp->sd_hash_bsize_shift = sdp->sd_sb.sb_bsize_shift - 1; - sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(uint64_t); + sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(u64); sdp->sd_qc_per_block = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header)) / sizeof(struct gfs2_quota_change); /* Compute maximum reservation required to add a entry to a directory */ - hash_blocks = DIV_ROUND_UP(sizeof(uint64_t) * (1 << GFS2_DIR_MAX_DEPTH), + hash_blocks = DIV_ROUND_UP(sizeof(u64) * (1 << GFS2_DIR_MAX_DEPTH), sdp->sd_jbsize); ind_blocks = 0; @@ -281,8 +281,8 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) sizeof(struct gfs2_dinode); sdp->sd_heightsize[1] = sdp->sd_sb.sb_bsize * sdp->sd_diptrs; for (x = 2;; x++) { - uint64_t space, d; - uint32_t m; + u64 space, d; + u32 m; space = sdp->sd_heightsize[x - 1] * sdp->sd_inptrs; d = space; @@ -299,8 +299,8 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent) sizeof(struct gfs2_dinode); sdp->sd_jheightsize[1] = sdp->sd_jbsize * sdp->sd_diptrs; for (x = 2;; x++) { - uint64_t space, d; - uint32_t m; + u64 space, d; + u32 m; space = sdp->sd_jheightsize[x - 1] * sdp->sd_inptrs; d = space; @@ -630,8 +630,8 @@ out: return 0; } -void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free, - int64_t dinodes) +void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free, + s64 dinodes) { struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode); struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; diff --git a/fs/gfs2/super.h b/fs/gfs2/super.h index 4a6ce9582743be..b073300a93e812 100644 --- a/fs/gfs2/super.h +++ b/fs/gfs2/super.h @@ -40,7 +40,7 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp); int gfs2_statfs_init(struct gfs2_sbd *sdp); void gfs2_statfs_change(struct gfs2_sbd *sdp, - int64_t total, int64_t free, int64_t dinodes); + s64 total, s64 free, s64 dinodes); int gfs2_statfs_sync(struct gfs2_sbd *sdp); int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc); int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc); diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index 79199738c3891c..8aefda22f98eda 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c @@ -138,7 +138,7 @@ static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf, static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf, size_t len) { - uint32_t id; + u32 id; if (!capable(CAP_SYS_ADMIN)) return -EACCES; @@ -152,7 +152,7 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf, static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf, size_t len) { - uint32_t id; + u32 id; if (!capable(CAP_SYS_ADMIN)) return -EACCES; diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index 8e18e634cbedcb..acf840160d5f75 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -46,7 +46,7 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks, tr->tr_reserved += 6 + blocks; if (revokes) tr->tr_reserved += gfs2_struct2blk(sdp, revokes, - sizeof(uint64_t)); + sizeof(u64)); INIT_LIST_HEAD(&tr->tr_list_buf); gfs2_holder_init(sdp->sd_trans_gl, LM_ST_SHARED, 0, &tr->tr_t_gh); @@ -142,7 +142,7 @@ void gfs2_trans_add_bh(struct gfs2_glock *gl, struct buffer_head *bh, int meta) lops_add(sdp, &bd->bd_le); } -void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, uint64_t blkno) +void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, u64 blkno) { struct gfs2_revoke *rv = kmalloc(sizeof(struct gfs2_revoke), GFP_NOFS | __GFP_NOFAIL); @@ -151,7 +151,7 @@ void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, uint64_t blkno) lops_add(sdp, &rv->rv_le); } -void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, uint64_t blkno) +void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, u64 blkno) { struct gfs2_revoke *rv; int found = 0; diff --git a/fs/gfs2/trans.h b/fs/gfs2/trans.h index 9e3ce84f6102f7..6550d3d18263fd 100644 --- a/fs/gfs2/trans.h +++ b/fs/gfs2/trans.h @@ -27,8 +27,8 @@ void gfs2_trans_end(struct gfs2_sbd *sdp); void gfs2_trans_add_gl(struct gfs2_glock *gl); void gfs2_trans_add_bh(struct gfs2_glock *gl, struct buffer_head *bh, int meta); -void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, uint64_t blkno); -void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, uint64_t blkno); +void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, u64 blkno); +void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, u64 blkno); void gfs2_trans_add_rg(struct gfs2_rgrpd *rgd); #endif /* __TRANS_DOT_H__ */ diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c index 2852431764c915..d72eb8addc7a03 100644 --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c @@ -171,7 +171,7 @@ int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, */ int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, - uint16_t type, uint16_t t, const char *function, + u16 type, u16 t, const char *function, char *file, unsigned int line) { int me; diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h index 60b370365eea6c..204fdb81e34de5 100644 --- a/fs/gfs2/util.h +++ b/fs/gfs2/util.h @@ -82,7 +82,7 @@ static inline int gfs2_meta_check_i(struct gfs2_sbd *sdp, char *file, unsigned int line) { struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data; - uint32_t magic = mh->mh_magic; + u32 magic = mh->mh_magic; magic = be32_to_cpu(magic); if (unlikely(magic != GFS2_MAGIC)) return gfs2_meta_check_ii(sdp, bh, "magic number", function, @@ -95,19 +95,19 @@ gfs2_meta_check_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__) int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, - uint16_t type, uint16_t t, + u16 type, u16 t, const char *function, char *file, unsigned int line); static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp, struct buffer_head *bh, - uint16_t type, + u16 type, const char *function, char *file, unsigned int line) { struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data; - uint32_t magic = mh->mh_magic; - uint16_t t = be32_to_cpu(mh->mh_type); + u32 magic = mh->mh_magic; + u16 t = be32_to_cpu(mh->mh_type); magic = be32_to_cpu(magic); if (unlikely(magic != GFS2_MAGIC)) return gfs2_meta_check_ii(sdp, bh, "magic number", function, @@ -121,8 +121,8 @@ static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp, #define gfs2_metatype_check(sdp, bh, type) \ gfs2_metatype_check_i((sdp), (bh), (type), __FUNCTION__, __FILE__, __LINE__) -static inline void gfs2_metatype_set(struct buffer_head *bh, uint16_t type, - uint16_t format) +static inline void gfs2_metatype_set(struct buffer_head *bh, u16 type, + u16 format) { struct gfs2_meta_header *mh; mh = (struct gfs2_meta_header *)bh->b_data; -- cgit 1.2.3-korg From b8547856f9c158ff70effbcfd15969c908fbe1b3 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Thu, 7 Sep 2006 13:12:27 -0400 Subject: [GFS2] Add gfs2 superblock to glock hash function This is another patch preparing for sharing of the glock hash table between different gfs2 mounts. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index f2edc8b761217d..00769674f2eabe 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -83,12 +83,14 @@ static inline int relaxed_state_ok(unsigned int actual, unsigned requested, * Returns: The number of the corresponding hash bucket */ -static unsigned int gl_hash(const struct lm_lockname *name) +static unsigned int gl_hash(const struct gfs2_sbd *sdp, + const struct lm_lockname *name) { unsigned int h; h = jhash(&name->ln_number, sizeof(u64), 0); h = jhash(&name->ln_type, sizeof(unsigned int), h); + h = jhash(&sdp, sizeof(struct gfs2_sbd *), h); h &= GFS2_GL_HASH_MASK; return h; @@ -232,7 +234,7 @@ static struct gfs2_glock *search_bucket(struct gfs2_gl_hash_bucket *bucket, static struct gfs2_glock *gfs2_glock_find(struct gfs2_sbd *sdp, const struct lm_lockname *name) { - struct gfs2_gl_hash_bucket *bucket = &sdp->sd_gl_hash[gl_hash(name)]; + struct gfs2_gl_hash_bucket *bucket = &sdp->sd_gl_hash[gl_hash(sdp, name)]; struct gfs2_glock *gl; read_lock(&bucket->hb_lock); @@ -266,7 +268,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, name.ln_number = number; name.ln_type = glops->go_type; - bucket = &sdp->sd_gl_hash[gl_hash(&name)]; + bucket = &sdp->sd_gl_hash[gl_hash(sdp, &name)]; read_lock(&bucket->hb_lock); gl = search_bucket(bucket, sdp, &name); -- cgit 1.2.3-korg From 85d1da67f7e1239afa3494d05be87da6fc3ecada Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Thu, 7 Sep 2006 14:40:21 -0400 Subject: [GFS2] Move glock hash table out of superblock There are several reasons why we want to do this: - Firstly its large and thus we'll scale better with multiple GFS2 fs mounted at the same time - Secondly its easier to scale its size as required (thats a plan for later patches) - Thirdly, we can use kzalloc rather than vmalloc when allocating the superblock (its now only 4888 bytes) - Fourth its all part of my plan to eventually be able to use RCU with the glock hash. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 54 +++++++++++++++++++++++++++++++++------------------- fs/gfs2/glock.h | 2 ++ fs/gfs2/incore.h | 12 +++++------- fs/gfs2/main.c | 6 +++++- fs/gfs2/ops_fstype.c | 9 +-------- 5 files changed, 47 insertions(+), 36 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 00769674f2eabe..5759f52a1cf9d6 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -49,6 +49,8 @@ typedef void (*glock_examiner) (struct gfs2_glock * gl); static int gfs2_dump_lockstate(struct gfs2_sbd *sdp); static int dump_glock(struct gfs2_glock *gl); +static struct gfs2_gl_hash_bucket gl_hash_table[GFS2_GL_HASH_SIZE]; + /** * relaxed_state_ok - is a requested lock compatible with the current lock mode? * @actual: the current state of the lock @@ -231,10 +233,10 @@ static struct gfs2_glock *search_bucket(struct gfs2_gl_hash_bucket *bucket, * Returns: NULL, or the struct gfs2_glock with the requested number */ -static struct gfs2_glock *gfs2_glock_find(struct gfs2_sbd *sdp, +static struct gfs2_glock *gfs2_glock_find(const struct gfs2_sbd *sdp, const struct lm_lockname *name) { - struct gfs2_gl_hash_bucket *bucket = &sdp->sd_gl_hash[gl_hash(sdp, name)]; + struct gfs2_gl_hash_bucket *bucket = &gl_hash_table[gl_hash(sdp, name)]; struct gfs2_glock *gl; read_lock(&bucket->hb_lock); @@ -268,7 +270,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, name.ln_number = number; name.ln_type = glops->go_type; - bucket = &sdp->sd_gl_hash[gl_hash(sdp, &name)]; + bucket = &gl_hash_table[gl_hash(sdp, &name)]; read_lock(&bucket->hb_lock); gl = search_bucket(bucket, sdp, &name); @@ -648,9 +650,9 @@ static void gfs2_glmutex_lock(struct gfs2_glock *gl) set_bit(HIF_MUTEX, &gh.gh_iflags); spin_lock(&gl->gl_spin); - if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) + if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) { list_add_tail(&gh.gh_list, &gl->gl_waiters1); - else { + } else { gl->gl_owner = current; gl->gl_ip = (unsigned long)__builtin_return_address(0); complete(&gh.gh_wait); @@ -673,9 +675,9 @@ static int gfs2_glmutex_trylock(struct gfs2_glock *gl) int acquired = 1; spin_lock(&gl->gl_spin); - if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) + if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) { acquired = 0; - else { + } else { gl->gl_owner = current; gl->gl_ip = (unsigned long)__builtin_return_address(0); } @@ -830,9 +832,9 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret) spin_lock(&gl->gl_spin); list_del_init(&gh->gh_list); if (gl->gl_state == gh->gh_state || - gl->gl_state == LM_ST_UNLOCKED) + gl->gl_state == LM_ST_UNLOCKED) { gh->gh_error = 0; - else { + } else { if (gfs2_assert_warn(sdp, gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) == -1) fs_warn(sdp, "ret = 0x%.8X\n", ret); @@ -1090,8 +1092,7 @@ static int glock_wait_internal(struct gfs2_holder *gh) return gh->gh_error; gfs2_assert_withdraw(sdp, test_bit(HIF_HOLDER, &gh->gh_iflags)); - gfs2_assert_withdraw(sdp, relaxed_state_ok(gl->gl_state, - gh->gh_state, + gfs2_assert_withdraw(sdp, relaxed_state_ok(gl->gl_state, gh->gh_state, gh->gh_flags)); if (test_bit(HIF_FIRST, &gh->gh_iflags)) { @@ -1901,6 +1902,8 @@ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, if (test_bit(GLF_PLUG, &gl->gl_flags)) continue; + if (gl->gl_sbd != sdp) + continue; /* examiner() must glock_put() */ gfs2_glock_hold(gl); @@ -1953,7 +1956,7 @@ void gfs2_scand_internal(struct gfs2_sbd *sdp) unsigned int x; for (x = 0; x < GFS2_GL_HASH_SIZE; x++) { - examine_bucket(scan_glock, sdp, &sdp->sd_gl_hash[x]); + examine_bucket(scan_glock, sdp, &gl_hash_table[x]); cond_resched(); } } @@ -2012,7 +2015,7 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait) cont = 0; for (x = 0; x < GFS2_GL_HASH_SIZE; x++) - if (examine_bucket(clear_glock, sdp, &sdp->sd_gl_hash[x])) + if (examine_bucket(clear_glock, sdp, &gl_hash_table[x])) cont = 1; if (!wait || !cont) @@ -2114,14 +2117,13 @@ static int dump_glock(struct gfs2_glock *gl) spin_lock(&gl->gl_spin); - printk(KERN_INFO "Glock 0x%p (%u, %llu)\n", - gl, - gl->gl_name.ln_type, + printk(KERN_INFO "Glock 0x%p (%u, %llu)\n", gl, gl->gl_name.ln_type, (unsigned long long)gl->gl_name.ln_number); printk(KERN_INFO " gl_flags ="); - for (x = 0; x < 32; x++) + for (x = 0; x < 32; x++) { if (test_bit(x, &gl->gl_flags)) printk(" %u", x); + } printk(" \n"); printk(KERN_INFO " gl_ref = %d\n", atomic_read(&gl->gl_ref.refcount)); printk(KERN_INFO " gl_state = %u\n", gl->gl_state); @@ -2136,8 +2138,7 @@ static int dump_glock(struct gfs2_glock *gl) printk(KERN_INFO " reclaim = %s\n", (list_empty(&gl->gl_reclaim)) ? "no" : "yes"); if (gl->gl_aspace) - printk(KERN_INFO " aspace = 0x%p nrpages = %lu\n", - gl->gl_aspace, + printk(KERN_INFO " aspace = 0x%p nrpages = %lu\n", gl->gl_aspace, gl->gl_aspace->i_mapping->nrpages); else printk(KERN_INFO " aspace = no\n"); @@ -2203,13 +2204,15 @@ static int gfs2_dump_lockstate(struct gfs2_sbd *sdp) int error = 0; for (x = 0; x < GFS2_GL_HASH_SIZE; x++) { - bucket = &sdp->sd_gl_hash[x]; + bucket = &gl_hash_table[x]; read_lock(&bucket->hb_lock); list_for_each_entry(gl, &bucket->hb_list, gl_list) { if (test_bit(GLF_PLUG, &gl->gl_flags)) continue; + if (gl->gl_sbd != sdp) + continue; error = dump_glock(gl); if (error) @@ -2226,3 +2229,14 @@ static int gfs2_dump_lockstate(struct gfs2_sbd *sdp) return error; } +int __init gfs2_glock_init(void) +{ + unsigned i; + for(i = 0; i < GFS2_GL_HASH_SIZE; i++) { + struct gfs2_gl_hash_bucket *hb = &gl_hash_table[i]; + rwlock_init(&hb->hb_lock); + INIT_LIST_HEAD(&hb->hb_list); + } + return 0; +} + diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 2e1d3286632101..0febca3d6d4710 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -150,4 +150,6 @@ void gfs2_reclaim_glock(struct gfs2_sbd *sdp); void gfs2_scand_internal(struct gfs2_sbd *sdp); void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait); +int __init gfs2_glock_init(void); + #endif /* __GLOCK_DOT_H__ */ diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 225924ca6b3ef6..61849607211f88 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -30,7 +30,6 @@ struct gfs2_quota_data; struct gfs2_trans; struct gfs2_ail; struct gfs2_jdesc; -struct gfs2_gl_hash_bucket; struct gfs2_sbd; typedef void (*gfs2_glop_bh_t) (struct gfs2_glock *gl, unsigned int ret); @@ -107,6 +106,11 @@ struct gfs2_bufdata { struct list_head bd_ail_gl_list; }; +struct gfs2_gl_hash_bucket { + rwlock_t hb_lock; + struct list_head hb_list; +}; + struct gfs2_glock_operations { void (*go_xmote_th) (struct gfs2_glock * gl, unsigned int state, int flags); @@ -442,11 +446,6 @@ struct gfs2_tune { unsigned int gt_statfs_slow; }; -struct gfs2_gl_hash_bucket { - rwlock_t hb_lock; - struct list_head hb_list; -}; - enum { SDF_JOURNAL_CHECKED = 0, SDF_JOURNAL_LIVE = 1, @@ -489,7 +488,6 @@ struct gfs2_sbd { /* Lock Stuff */ struct lm_lockstruct sd_lockstruct; - struct gfs2_gl_hash_bucket sd_gl_hash[GFS2_GL_HASH_SIZE]; struct list_head sd_reclaim_list; spinlock_t sd_reclaim_lock; wait_queue_head_t sd_reclaim_wq; diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index 143fda727a9cb7..2bdf246436c722 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c @@ -23,6 +23,7 @@ #include "ops_fstype.h" #include "sys.h" #include "util.h" +#include "glock.h" static void gfs2_init_inode_once(void *foo, kmem_cache_t *cachep, unsigned long flags) { @@ -69,8 +70,11 @@ static int __init init_gfs2_fs(void) if (error) return error; - error = -ENOMEM; + error = gfs2_glock_init(); + if (error) + goto fail; + error = -ENOMEM; gfs2_glock_cachep = kmem_cache_create("gfs2_glock", sizeof(struct gfs2_glock), 0, 0, diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index c94422b30ceb8f..f5140bdc1027b4 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -45,23 +45,16 @@ extern struct dentry_operations gfs2_dops; static struct gfs2_sbd *init_sbd(struct super_block *sb) { struct gfs2_sbd *sdp; - unsigned int x; - sdp = vmalloc(sizeof(struct gfs2_sbd)); + sdp = kzalloc(sizeof(struct gfs2_sbd), GFP_KERNEL); if (!sdp) return NULL; - memset(sdp, 0, sizeof(struct gfs2_sbd)); - sb->s_fs_info = sdp; sdp->sd_vfs = sb; gfs2_tune_init(&sdp->sd_tune); - for (x = 0; x < GFS2_GL_HASH_SIZE; x++) { - rwlock_init(&sdp->sd_gl_hash[x].hb_lock); - INIT_LIST_HEAD(&sdp->sd_gl_hash[x].hb_list); - } INIT_LIST_HEAD(&sdp->sd_reclaim_list); spin_lock_init(&sdp->sd_reclaim_lock); init_waitqueue_head(&sdp->sd_reclaim_wq); -- cgit 1.2.3-korg From 1c089c325d5cda0f64a3cf8edf3aaafa148f200a Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Thu, 7 Sep 2006 15:50:20 -0400 Subject: [GFS2] Remove one typedef This removes one of the typedefs from the locking interface. It is replaced by a forward declaration of the gfs2 superblock. The other two are not so easy to solve since in their case, they can refer to one of two possible structures. Cc: David Teigland Cc: Jan Engelhardt Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 5 ++--- fs/gfs2/glock.h | 2 +- fs/gfs2/lm_interface.h | 9 ++++----- fs/gfs2/locking.c | 6 +++--- fs/gfs2/locking/dlm/lock_dlm.h | 2 +- fs/gfs2/locking/dlm/mount.c | 8 ++++---- fs/gfs2/locking/dlm/sysfs.c | 2 +- fs/gfs2/locking/dlm/thread.c | 6 +++--- fs/gfs2/locking/nolock/main.c | 2 +- 9 files changed, 20 insertions(+), 22 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 5759f52a1cf9d6..87b37fe269b673 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1704,7 +1704,7 @@ static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name, /** * gfs2_glock_cb - Callback used by locking module - * @fsdata: Pointer to the superblock + * @sdp: Pointer to the superblock * @type: Type of callback * @data: Type dependent data pointer * @@ -1713,9 +1713,8 @@ static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name, * a journal from another client needs to be recovered. */ -void gfs2_glock_cb(lm_fsdata_t *fsdata, unsigned int type, void *data) +void gfs2_glock_cb(struct gfs2_sbd *sdp, unsigned int type, void *data) { - struct gfs2_sbd *sdp = (struct gfs2_sbd *)fsdata; switch (type) { case LM_CB_NEED_E: diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 0febca3d6d4710..e3bf4bcd4b292a 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -140,7 +140,7 @@ static inline int gfs2_glock_nq_init(struct gfs2_glock *gl, int gfs2_lvb_hold(struct gfs2_glock *gl); void gfs2_lvb_unhold(struct gfs2_glock *gl); -void gfs2_glock_cb(lm_fsdata_t *fsdata, unsigned int type, void *data); +void gfs2_glock_cb(struct gfs2_sbd *sdp, unsigned int type, void *data); void gfs2_iopen_go_callback(struct gfs2_glock *gl, unsigned int state); diff --git a/fs/gfs2/lm_interface.h b/fs/gfs2/lm_interface.h index e2dfc3da4da963..75835e0f425466 100644 --- a/fs/gfs2/lm_interface.h +++ b/fs/gfs2/lm_interface.h @@ -17,10 +17,9 @@ typedef void lm_lockspace_t; typedef void lm_lock_t; -typedef void lm_fsdata_t; +struct gfs2_sbd; -typedef void (*lm_callback_t) (lm_fsdata_t *fsdata, unsigned int type, - void *data); +typedef void (*lm_callback_t) (struct gfs2_sbd *sdp, unsigned int type, void *data); /* * lm_mount() flags @@ -183,7 +182,7 @@ struct lm_lockops { */ int (*lm_mount) (char *table_name, char *host_data, - lm_callback_t cb, lm_fsdata_t *fsdata, + lm_callback_t cb, struct gfs2_sbd *sdp, unsigned int min_lvb_size, int flags, struct lm_lockstruct *lockstruct, struct kobject *fskobj); @@ -275,7 +274,7 @@ void gfs2_unregister_lockproto(struct lm_lockops *proto); */ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data, - lm_callback_t cb, lm_fsdata_t *fsdata, + lm_callback_t cb, struct gfs2_sbd *sdp, unsigned int min_lvb_size, int flags, struct lm_lockstruct *lockstruct, struct kobject *fskobj); diff --git a/fs/gfs2/locking.c b/fs/gfs2/locking.c index fce2001e5e256a..31421ee6d863a6 100644 --- a/fs/gfs2/locking.c +++ b/fs/gfs2/locking.c @@ -99,7 +99,7 @@ void gfs2_unregister_lockproto(struct lm_lockops *proto) * @table_name - the name of the lock space * @host_data - data specific to this host * @cb - the callback to the code using the lock module - * @fsdata - data to pass back with the callback + * @sdp - The GFS2 superblock * @min_lvb_size - the mininum LVB size that the caller can deal with * @flags - LM_MFLAG_* * @lockstruct - a structure returned describing the mount @@ -108,7 +108,7 @@ void gfs2_unregister_lockproto(struct lm_lockops *proto) */ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data, - lm_callback_t cb, lm_fsdata_t *fsdata, + lm_callback_t cb, struct gfs2_sbd *sdp, unsigned int min_lvb_size, int flags, struct lm_lockstruct *lockstruct, struct kobject *fskobj) @@ -147,7 +147,7 @@ retry: goto retry; } - error = lw->lw_ops->lm_mount(table_name, host_data, cb, fsdata, + error = lw->lw_ops->lm_mount(table_name, host_data, cb, sdp, min_lvb_size, flags, lockstruct, fskobj); if (error) module_put(lw->lw_ops->lm_owner); diff --git a/fs/gfs2/locking/dlm/lock_dlm.h b/fs/gfs2/locking/dlm/lock_dlm.h index c7b6e370258f60..e6898d236521b8 100644 --- a/fs/gfs2/locking/dlm/lock_dlm.h +++ b/fs/gfs2/locking/dlm/lock_dlm.h @@ -67,7 +67,7 @@ struct gdlm_ls { int fsflags; dlm_lockspace_t *dlm_lockspace; lm_callback_t fscb; - lm_fsdata_t *fsdata; + struct gfs2_sbd *sdp; int recover_jid; int recover_jid_done; int recover_jid_status; diff --git a/fs/gfs2/locking/dlm/mount.c b/fs/gfs2/locking/dlm/mount.c index 82ac00af84a38e..8a1764f4d71cbf 100644 --- a/fs/gfs2/locking/dlm/mount.c +++ b/fs/gfs2/locking/dlm/mount.c @@ -14,7 +14,7 @@ int gdlm_drop_period; struct lm_lockops gdlm_ops; -static struct gdlm_ls *init_gdlm(lm_callback_t cb, lm_fsdata_t *fsdata, +static struct gdlm_ls *init_gdlm(lm_callback_t cb, struct gfs2_sbd *sdp, int flags, char *table_name) { struct gdlm_ls *ls; @@ -27,7 +27,7 @@ static struct gdlm_ls *init_gdlm(lm_callback_t cb, lm_fsdata_t *fsdata, ls->drop_locks_count = gdlm_drop_count; ls->drop_locks_period = gdlm_drop_period; ls->fscb = cb; - ls->fsdata = fsdata; + ls->sdp = sdp; ls->fsflags = flags; spin_lock_init(&ls->async_lock); INIT_LIST_HEAD(&ls->complete); @@ -120,7 +120,7 @@ static int make_args(struct gdlm_ls *ls, char *data_arg, int *nodir) } static int gdlm_mount(char *table_name, char *host_data, - lm_callback_t cb, lm_fsdata_t *fsdata, + lm_callback_t cb, struct gfs2_sbd *sdp, unsigned int min_lvb_size, int flags, struct lm_lockstruct *lockstruct, struct kobject *fskobj) @@ -131,7 +131,7 @@ static int gdlm_mount(char *table_name, char *host_data, if (min_lvb_size > GDLM_LVB_SIZE) goto out; - ls = init_gdlm(cb, fsdata, flags, table_name); + ls = init_gdlm(cb, sdp, flags, table_name); if (!ls) goto out; diff --git a/fs/gfs2/locking/dlm/sysfs.c b/fs/gfs2/locking/dlm/sysfs.c index c1237a91fc683d..29ae06f949445c 100644 --- a/fs/gfs2/locking/dlm/sysfs.c +++ b/fs/gfs2/locking/dlm/sysfs.c @@ -102,7 +102,7 @@ static ssize_t recover_show(struct gdlm_ls *ls, char *buf) static ssize_t recover_store(struct gdlm_ls *ls, const char *buf, size_t len) { ls->recover_jid = simple_strtol(buf, NULL, 0); - ls->fscb(ls->fsdata, LM_CB_NEED_RECOVERY, &ls->recover_jid); + ls->fscb(ls->sdp, LM_CB_NEED_RECOVERY, &ls->recover_jid); return len; } diff --git a/fs/gfs2/locking/dlm/thread.c b/fs/gfs2/locking/dlm/thread.c index d4895ec242f61d..554bf882a4c2bf 100644 --- a/fs/gfs2/locking/dlm/thread.c +++ b/fs/gfs2/locking/dlm/thread.c @@ -41,7 +41,7 @@ static void process_blocking(struct gdlm_lock *lp, int bast_mode) gdlm_assert(0, "unknown bast mode %u", lp->bast_mode); } - ls->fscb(ls->fsdata, cb, &lp->lockname); + ls->fscb(ls->sdp, cb, &lp->lockname); } static void process_complete(struct gdlm_lock *lp) @@ -232,7 +232,7 @@ out: (lp->cur > DLM_LOCK_NL) && (prev_mode > DLM_LOCK_NL)) acb.lc_ret |= LM_OUT_CACHEABLE; - ls->fscb(ls->fsdata, LM_CB_ASYNC, &acb); + ls->fscb(ls->sdp, LM_CB_ASYNC, &acb); } static inline int no_work(struct gdlm_ls *ls, int blocking) @@ -318,7 +318,7 @@ static int gdlm_thread(void *data) gdlm_do_lock(lp); if (drop) - ls->fscb(ls->fsdata, LM_CB_DROPLOCKS, NULL); + ls->fscb(ls->sdp, LM_CB_DROPLOCKS, NULL); schedule(); } diff --git a/fs/gfs2/locking/nolock/main.c b/fs/gfs2/locking/nolock/main.c index 95a29914730aec..e326079430a263 100644 --- a/fs/gfs2/locking/nolock/main.c +++ b/fs/gfs2/locking/nolock/main.c @@ -24,7 +24,7 @@ struct nolock_lockspace { static struct lm_lockops nolock_ops; static int nolock_mount(char *table_name, char *host_data, - lm_callback_t cb, lm_fsdata_t *fsdata, + lm_callback_t cb, struct gfs2_sbd *sdp, unsigned int min_lvb_size, int flags, struct lm_lockstruct *lockstruct, struct kobject *fskobj) -- cgit 1.2.3-korg From 9b47c11d1cbedcba685c9bd90c73fd41acdfab0e Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Fri, 8 Sep 2006 10:17:58 -0400 Subject: [GFS2] Use void * instead of typedef for locking module interface As requested by Jan Engelhardt, this removes the typedefs in the locking module interface and replaces them with void *. Also since we are changing the interface, I've added a few consts as well. Cc: Jan Engelhardt Cc: David Teigland Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 3 ++- fs/gfs2/glock.h | 2 +- fs/gfs2/incore.h | 2 +- fs/gfs2/lm.c | 14 +++++------ fs/gfs2/lm.h | 14 +++++------ fs/gfs2/lm_interface.h | 57 ++++++++++++++++-------------------------- fs/gfs2/locking.c | 10 ++++---- fs/gfs2/locking/dlm/lock.c | 32 ++++++++++++------------ fs/gfs2/locking/dlm/lock_dlm.h | 22 ++++++++-------- fs/gfs2/locking/dlm/mount.c | 24 +++++++++--------- fs/gfs2/locking/dlm/plock.c | 15 ++++++----- fs/gfs2/locking/nolock/main.c | 44 ++++++++++++++++---------------- 12 files changed, 113 insertions(+), 126 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 87b37fe269b673..92aa0e8c90992d 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1713,8 +1713,9 @@ static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name, * a journal from another client needs to be recovered. */ -void gfs2_glock_cb(struct gfs2_sbd *sdp, unsigned int type, void *data) +void gfs2_glock_cb(void *cb_data, unsigned int type, void *data) { + struct gfs2_sbd *sdp = cb_data; switch (type) { case LM_CB_NEED_E: diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index e3bf4bcd4b292a..52b8a308635ab8 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -140,7 +140,7 @@ static inline int gfs2_glock_nq_init(struct gfs2_glock *gl, int gfs2_lvb_hold(struct gfs2_glock *gl); void gfs2_lvb_unhold(struct gfs2_glock *gl); -void gfs2_glock_cb(struct gfs2_sbd *sdp, unsigned int type, void *data); +void gfs2_glock_cb(void *cb_data, unsigned int type, void *data); void gfs2_iopen_go_callback(struct gfs2_glock *gl, unsigned int state); diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 61849607211f88..9f5d98ff823ab9 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -187,7 +187,7 @@ struct gfs2_glock { struct gfs2_holder *gl_req_gh; gfs2_glop_bh_t gl_req_bh; - lm_lock_t *gl_lock; + void *gl_lock; char *gl_lvb; atomic_t gl_lvb_count; diff --git a/fs/gfs2/lm.c b/fs/gfs2/lm.c index e60f95cae6c552..4e23aa5ef75d3b 100644 --- a/fs/gfs2/lm.c +++ b/fs/gfs2/lm.c @@ -122,7 +122,7 @@ int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...) } int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name, - lm_lock_t **lockp) + void **lockp) { int error = -EIO; if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) @@ -131,13 +131,13 @@ int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name, return error; } -void gfs2_lm_put_lock(struct gfs2_sbd *sdp, lm_lock_t *lock) +void gfs2_lm_put_lock(struct gfs2_sbd *sdp, void *lock) { if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) sdp->sd_lockstruct.ls_ops->lm_put_lock(lock); } -unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, lm_lock_t *lock, +unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock, unsigned int cur_state, unsigned int req_state, unsigned int flags) { @@ -148,7 +148,7 @@ unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, lm_lock_t *lock, return ret; } -unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, lm_lock_t *lock, +unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, void *lock, unsigned int cur_state) { int ret = 0; @@ -157,13 +157,13 @@ unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, lm_lock_t *lock, return ret; } -void gfs2_lm_cancel(struct gfs2_sbd *sdp, lm_lock_t *lock) +void gfs2_lm_cancel(struct gfs2_sbd *sdp, void *lock) { if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) sdp->sd_lockstruct.ls_ops->lm_cancel(lock); } -int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char **lvbp) +int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, void *lock, char **lvbp) { int error = -EIO; if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) @@ -171,7 +171,7 @@ int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char **lvbp) return error; } -void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb) +void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, void *lock, char *lvb) { if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(lock, lvb); diff --git a/fs/gfs2/lm.h b/fs/gfs2/lm.h index 6b890e73e6c1c7..21cdc30ee08c50 100644 --- a/fs/gfs2/lm.h +++ b/fs/gfs2/lm.h @@ -20,16 +20,16 @@ void gfs2_lm_unmount(struct gfs2_sbd *sdp); int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...) __attribute__ ((format(printf, 2, 3))); int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name, - lm_lock_t **lockp); -void gfs2_lm_put_lock(struct gfs2_sbd *sdp, lm_lock_t *lock); -unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, lm_lock_t *lock, + void **lockp); +void gfs2_lm_put_lock(struct gfs2_sbd *sdp, void *lock); +unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock, unsigned int cur_state, unsigned int req_state, unsigned int flags); -unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, lm_lock_t *lock, +unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, void *lock, unsigned int cur_state); -void gfs2_lm_cancel(struct gfs2_sbd *sdp, lm_lock_t *lock); -int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char **lvbp); -void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb); +void gfs2_lm_cancel(struct gfs2_sbd *sdp, void *lock); +int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, void *lock, char **lvbp); +void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, void *lock, char *lvb); int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name, struct file *file, struct file_lock *fl); int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name, diff --git a/fs/gfs2/lm_interface.h b/fs/gfs2/lm_interface.h index 148136a3462556..1418fdc9ac0261 100644 --- a/fs/gfs2/lm_interface.h +++ b/fs/gfs2/lm_interface.h @@ -10,16 +10,8 @@ #ifndef __LM_INTERFACE_DOT_H__ #define __LM_INTERFACE_DOT_H__ -/* - * Opaque handles represent the lock module's lockspace structure, the lock - * module's lock structures, and GFS's file system (superblock) structure. - */ -typedef void lm_lockspace_t; -typedef void lm_lock_t; -struct gfs2_sbd; - -typedef void (*lm_callback_t) (struct gfs2_sbd *sdp, unsigned int type, void *data); +typedef void (*lm_callback_t) (void *ptr, unsigned int type, void *data); /* * lm_mount() flags @@ -175,64 +167,60 @@ struct lm_async_cb { struct lm_lockstruct; struct lm_lockops { - char lm_proto_name[256]; + const char *lm_proto_name; /* * Mount/Unmount */ int (*lm_mount) (char *table_name, char *host_data, - lm_callback_t cb, struct gfs2_sbd *sdp, + lm_callback_t cb, void *cb_data, unsigned int min_lvb_size, int flags, struct lm_lockstruct *lockstruct, struct kobject *fskobj); - void (*lm_others_may_mount) (lm_lockspace_t *lockspace); + void (*lm_others_may_mount) (void *lockspace); - void (*lm_unmount) (lm_lockspace_t *lockspace); + void (*lm_unmount) (void *lockspace); - void (*lm_withdraw) (lm_lockspace_t *lockspace); + void (*lm_withdraw) (void *lockspace); /* * Lock oriented operations */ - int (*lm_get_lock) (lm_lockspace_t *lockspace, - struct lm_lockname *name, lm_lock_t **lockp); + int (*lm_get_lock) (void *lockspace, struct lm_lockname *name, void **lockp); - void (*lm_put_lock) (lm_lock_t *lock); + void (*lm_put_lock) (void *lock); - unsigned int (*lm_lock) (lm_lock_t *lock, unsigned int cur_state, + unsigned int (*lm_lock) (void *lock, unsigned int cur_state, unsigned int req_state, unsigned int flags); - unsigned int (*lm_unlock) (lm_lock_t *lock, unsigned int cur_state); + unsigned int (*lm_unlock) (void *lock, unsigned int cur_state); - void (*lm_cancel) (lm_lock_t *lock); + void (*lm_cancel) (void *lock); - int (*lm_hold_lvb) (lm_lock_t *lock, char **lvbp); - void (*lm_unhold_lvb) (lm_lock_t *lock, char *lvb); + int (*lm_hold_lvb) (void *lock, char **lvbp); + void (*lm_unhold_lvb) (void *lock, char *lvb); /* * Posix Lock oriented operations */ - int (*lm_plock_get) (lm_lockspace_t *lockspace, - struct lm_lockname *name, + int (*lm_plock_get) (void *lockspace, struct lm_lockname *name, struct file *file, struct file_lock *fl); - int (*lm_plock) (lm_lockspace_t *lockspace, - struct lm_lockname *name, + int (*lm_plock) (void *lockspace, struct lm_lockname *name, struct file *file, int cmd, struct file_lock *fl); - int (*lm_punlock) (lm_lockspace_t *lockspace, - struct lm_lockname *name, + int (*lm_punlock) (void *lockspace, struct lm_lockname *name, struct file *file, struct file_lock *fl); /* * Client oriented operations */ - void (*lm_recovery_done) (lm_lockspace_t *lockspace, unsigned int jid, + void (*lm_recovery_done) (void *lockspace, unsigned int jid, unsigned int message); struct module *lm_owner; @@ -253,8 +241,8 @@ struct lm_lockstruct { unsigned int ls_jid; unsigned int ls_first; unsigned int ls_lvb_size; - lm_lockspace_t *ls_lockspace; - struct lm_lockops *ls_ops; + void *ls_lockspace; + const struct lm_lockops *ls_ops; int ls_flags; }; @@ -263,9 +251,8 @@ struct lm_lockstruct { * with these functions. */ -int gfs2_register_lockproto(struct lm_lockops *proto); - -void gfs2_unregister_lockproto(struct lm_lockops *proto); +int gfs2_register_lockproto(const struct lm_lockops *proto); +void gfs2_unregister_lockproto(const struct lm_lockops *proto); /* * Lock module top interface. GFS calls these functions when mounting or @@ -273,7 +260,7 @@ void gfs2_unregister_lockproto(struct lm_lockops *proto); */ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data, - lm_callback_t cb, struct gfs2_sbd *sdp, + lm_callback_t cb, void *cb_data, unsigned int min_lvb_size, int flags, struct lm_lockstruct *lockstruct, struct kobject *fskobj); diff --git a/fs/gfs2/locking.c b/fs/gfs2/locking.c index 31421ee6d863a6..65eca48b2eae23 100644 --- a/fs/gfs2/locking.c +++ b/fs/gfs2/locking.c @@ -21,7 +21,7 @@ struct lmh_wrapper { struct list_head lw_list; - struct lm_lockops *lw_ops; + const struct lm_lockops *lw_ops; }; /* List of registered low-level locking protocols. A file system selects one @@ -37,7 +37,7 @@ static DEFINE_MUTEX(lmh_lock); * Returns: 0 on success, -EXXX on failure */ -int gfs2_register_lockproto(struct lm_lockops *proto) +int gfs2_register_lockproto(const struct lm_lockops *proto) { struct lmh_wrapper *lw; @@ -72,7 +72,7 @@ int gfs2_register_lockproto(struct lm_lockops *proto) * */ -void gfs2_unregister_lockproto(struct lm_lockops *proto) +void gfs2_unregister_lockproto(const struct lm_lockops *proto) { struct lmh_wrapper *lw; @@ -108,7 +108,7 @@ void gfs2_unregister_lockproto(struct lm_lockops *proto) */ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data, - lm_callback_t cb, struct gfs2_sbd *sdp, + lm_callback_t cb, void *cb_data, unsigned int min_lvb_size, int flags, struct lm_lockstruct *lockstruct, struct kobject *fskobj) @@ -147,7 +147,7 @@ retry: goto retry; } - error = lw->lw_ops->lm_mount(table_name, host_data, cb, sdp, + error = lw->lw_ops->lm_mount(table_name, host_data, cb, cb_data, min_lvb_size, flags, lockstruct, fskobj); if (error) module_put(lw->lw_ops->lm_owner); diff --git a/fs/gfs2/locking/dlm/lock.c b/fs/gfs2/locking/dlm/lock.c index e4359b1b7174ba..b167addf9fd185 100644 --- a/fs/gfs2/locking/dlm/lock.c +++ b/fs/gfs2/locking/dlm/lock.c @@ -207,21 +207,21 @@ void gdlm_delete_lp(struct gdlm_lock *lp) kfree(lp); } -int gdlm_get_lock(lm_lockspace_t *lockspace, struct lm_lockname *name, - lm_lock_t **lockp) +int gdlm_get_lock(void *lockspace, struct lm_lockname *name, + void **lockp) { struct gdlm_lock *lp; int error; - error = gdlm_create_lp((struct gdlm_ls *) lockspace, name, &lp); + error = gdlm_create_lp(lockspace, name, &lp); - *lockp = (lm_lock_t *) lp; + *lockp = lp; return error; } -void gdlm_put_lock(lm_lock_t *lock) +void gdlm_put_lock(void *lock) { - gdlm_delete_lp((struct gdlm_lock *) lock); + gdlm_delete_lp(lock); } unsigned int gdlm_do_lock(struct gdlm_lock *lp) @@ -305,10 +305,10 @@ static unsigned int gdlm_do_unlock(struct gdlm_lock *lp) return LM_OUT_ASYNC; } -unsigned int gdlm_lock(lm_lock_t *lock, unsigned int cur_state, +unsigned int gdlm_lock(void *lock, unsigned int cur_state, unsigned int req_state, unsigned int flags) { - struct gdlm_lock *lp = (struct gdlm_lock *) lock; + struct gdlm_lock *lp = lock; clear_bit(LFL_DLM_CANCEL, &lp->flags); if (flags & LM_FLAG_NOEXP) @@ -321,9 +321,9 @@ unsigned int gdlm_lock(lm_lock_t *lock, unsigned int cur_state, return gdlm_do_lock(lp); } -unsigned int gdlm_unlock(lm_lock_t *lock, unsigned int cur_state) +unsigned int gdlm_unlock(void *lock, unsigned int cur_state) { - struct gdlm_lock *lp = (struct gdlm_lock *) lock; + struct gdlm_lock *lp = lock; clear_bit(LFL_DLM_CANCEL, &lp->flags); if (lp->cur == DLM_LOCK_IV) @@ -331,9 +331,9 @@ unsigned int gdlm_unlock(lm_lock_t *lock, unsigned int cur_state) return gdlm_do_unlock(lp); } -void gdlm_cancel(lm_lock_t *lock) +void gdlm_cancel(void *lock) { - struct gdlm_lock *lp = (struct gdlm_lock *) lock; + struct gdlm_lock *lp = lock; struct gdlm_ls *ls = lp->ls; int error, delay_list = 0; @@ -464,9 +464,9 @@ static void unhold_null_lock(struct gdlm_lock *lp) intact on the resource while the lvb is "held" even if it's holding no locks on the resource. */ -int gdlm_hold_lvb(lm_lock_t *lock, char **lvbp) +int gdlm_hold_lvb(void *lock, char **lvbp) { - struct gdlm_lock *lp = (struct gdlm_lock *) lock; + struct gdlm_lock *lp = lock; int error; error = gdlm_add_lvb(lp); @@ -482,9 +482,9 @@ int gdlm_hold_lvb(lm_lock_t *lock, char **lvbp) return error; } -void gdlm_unhold_lvb(lm_lock_t *lock, char *lvb) +void gdlm_unhold_lvb(void *lock, char *lvb) { - struct gdlm_lock *lp = (struct gdlm_lock *) lock; + struct gdlm_lock *lp = lock; unhold_null_lock(lp); gdlm_del_lvb(lp); diff --git a/fs/gfs2/locking/dlm/lock_dlm.h b/fs/gfs2/locking/dlm/lock_dlm.h index a4f534a0ecffe4..3a45c020d01e31 100644 --- a/fs/gfs2/locking/dlm/lock_dlm.h +++ b/fs/gfs2/locking/dlm/lock_dlm.h @@ -112,7 +112,7 @@ struct gdlm_lock { s16 cur; s16 req; s16 prev_req; - u32 lkf; /* dlm flags DLM_LKF_ */ + u32 lkf; /* dlm flags DLM_LKF_ */ unsigned long flags; /* lock_dlm flags LFL_ */ int bast_mode; /* protected by async_lock */ @@ -165,23 +165,23 @@ int gdlm_release_all_locks(struct gdlm_ls *); void gdlm_delete_lp(struct gdlm_lock *); unsigned int gdlm_do_lock(struct gdlm_lock *); -int gdlm_get_lock(lm_lockspace_t *, struct lm_lockname *, lm_lock_t **); -void gdlm_put_lock(lm_lock_t *); -unsigned int gdlm_lock(lm_lock_t *, unsigned int, unsigned int, unsigned int); -unsigned int gdlm_unlock(lm_lock_t *, unsigned int); -void gdlm_cancel(lm_lock_t *); -int gdlm_hold_lvb(lm_lock_t *, char **); -void gdlm_unhold_lvb(lm_lock_t *, char *); +int gdlm_get_lock(void *, struct lm_lockname *, void **); +void gdlm_put_lock(void *); +unsigned int gdlm_lock(void *, unsigned int, unsigned int, unsigned int); +unsigned int gdlm_unlock(void *, unsigned int); +void gdlm_cancel(void *); +int gdlm_hold_lvb(void *, char **); +void gdlm_unhold_lvb(void *, char *); /* plock.c */ int gdlm_plock_init(void); void gdlm_plock_exit(void); -int gdlm_plock(lm_lockspace_t *, struct lm_lockname *, struct file *, int, +int gdlm_plock(void *, struct lm_lockname *, struct file *, int, struct file_lock *); -int gdlm_plock_get(lm_lockspace_t *, struct lm_lockname *, struct file *, +int gdlm_plock_get(void *, struct lm_lockname *, struct file *, struct file_lock *); -int gdlm_punlock(lm_lockspace_t *, struct lm_lockname *, struct file *, +int gdlm_punlock(void *, struct lm_lockname *, struct file *, struct file_lock *); #endif diff --git a/fs/gfs2/locking/dlm/mount.c b/fs/gfs2/locking/dlm/mount.c index 832fb819a2b522..1f94dd35a94355 100644 --- a/fs/gfs2/locking/dlm/mount.c +++ b/fs/gfs2/locking/dlm/mount.c @@ -11,7 +11,7 @@ int gdlm_drop_count; int gdlm_drop_period; -struct lm_lockops gdlm_ops; +const struct lm_lockops gdlm_ops; static struct gdlm_ls *init_gdlm(lm_callback_t cb, struct gfs2_sbd *sdp, @@ -120,7 +120,7 @@ static int make_args(struct gdlm_ls *ls, char *data_arg, int *nodir) } static int gdlm_mount(char *table_name, char *host_data, - lm_callback_t cb, struct gfs2_sbd *sdp, + lm_callback_t cb, void *cb_data, unsigned int min_lvb_size, int flags, struct lm_lockstruct *lockstruct, struct kobject *fskobj) @@ -131,7 +131,7 @@ static int gdlm_mount(char *table_name, char *host_data, if (min_lvb_size > GDLM_LVB_SIZE) goto out; - ls = init_gdlm(cb, sdp, flags, table_name); + ls = init_gdlm(cb, cb_data, flags, table_name); if (!ls) goto out; @@ -174,9 +174,9 @@ out: return error; } -static void gdlm_unmount(lm_lockspace_t *lockspace) +static void gdlm_unmount(void *lockspace) { - struct gdlm_ls *ls = (struct gdlm_ls *) lockspace; + struct gdlm_ls *ls = lockspace; int rv; log_debug("unmount flags %lx", ls->flags); @@ -198,18 +198,18 @@ out: kfree(ls); } -static void gdlm_recovery_done(lm_lockspace_t *lockspace, unsigned int jid, +static void gdlm_recovery_done(void *lockspace, unsigned int jid, unsigned int message) { - struct gdlm_ls *ls = (struct gdlm_ls *) lockspace; + struct gdlm_ls *ls = lockspace; ls->recover_jid_done = jid; ls->recover_jid_status = message; kobject_uevent(&ls->kobj, KOBJ_CHANGE); } -static void gdlm_others_may_mount(lm_lockspace_t *lockspace) +static void gdlm_others_may_mount(void *lockspace) { - struct gdlm_ls *ls = (struct gdlm_ls *) lockspace; + struct gdlm_ls *ls = lockspace; ls->first_done = 1; kobject_uevent(&ls->kobj, KOBJ_CHANGE); } @@ -218,9 +218,9 @@ static void gdlm_others_may_mount(lm_lockspace_t *lockspace) other mounters, and lets us know (sets WITHDRAW flag). Then, userspace leaves the mount group while we leave the lockspace. */ -static void gdlm_withdraw(lm_lockspace_t *lockspace) +static void gdlm_withdraw(void *lockspace) { - struct gdlm_ls *ls = (struct gdlm_ls *) lockspace; + struct gdlm_ls *ls = lockspace; kobject_uevent(&ls->kobj, KOBJ_OFFLINE); @@ -233,7 +233,7 @@ static void gdlm_withdraw(lm_lockspace_t *lockspace) gdlm_kobject_release(ls); } -struct lm_lockops gdlm_ops = { +const struct lm_lockops gdlm_ops = { .lm_proto_name = "lock_dlm", .lm_mount = gdlm_mount, .lm_others_may_mount = gdlm_others_may_mount, diff --git a/fs/gfs2/locking/dlm/plock.c b/fs/gfs2/locking/dlm/plock.c index 263636b390febf..7365aec9511b67 100644 --- a/fs/gfs2/locking/dlm/plock.c +++ b/fs/gfs2/locking/dlm/plock.c @@ -58,10 +58,10 @@ static void send_op(struct plock_op *op) wake_up(&send_wq); } -int gdlm_plock(lm_lockspace_t *lockspace, struct lm_lockname *name, +int gdlm_plock(void *lockspace, struct lm_lockname *name, struct file *file, int cmd, struct file_lock *fl) { - struct gdlm_ls *ls = (struct gdlm_ls *) lockspace; + struct gdlm_ls *ls = lockspace; struct plock_op *op; int rv; @@ -102,10 +102,10 @@ int gdlm_plock(lm_lockspace_t *lockspace, struct lm_lockname *name, return rv; } -int gdlm_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name, +int gdlm_punlock(void *lockspace, struct lm_lockname *name, struct file *file, struct file_lock *fl) { - struct gdlm_ls *ls = (struct gdlm_ls *) lockspace; + struct gdlm_ls *ls = lockspace; struct plock_op *op; int rv; @@ -141,10 +141,10 @@ int gdlm_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name, return rv; } -int gdlm_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name, +int gdlm_plock_get(void *lockspace, struct lm_lockname *name, struct file *file, struct file_lock *fl) { - struct gdlm_ls *ls = (struct gdlm_ls *) lockspace; + struct gdlm_ls *ls = lockspace; struct plock_op *op; int rv; @@ -231,8 +231,7 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count, spin_lock(&ops_lock); list_for_each_entry(op, &recv_list, list) { - if (op->info.fsid == info.fsid && - op->info.number == info.number && + if (op->info.fsid == info.fsid && op->info.number == info.number && op->info.owner == info.owner) { list_del_init(&op->list); found = 1; diff --git a/fs/gfs2/locking/nolock/main.c b/fs/gfs2/locking/nolock/main.c index ba7399787f621e..7b263fc6c27372 100644 --- a/fs/gfs2/locking/nolock/main.c +++ b/fs/gfs2/locking/nolock/main.c @@ -21,10 +21,10 @@ struct nolock_lockspace { unsigned int nl_lvb_size; }; -static struct lm_lockops nolock_ops; +static const struct lm_lockops nolock_ops; static int nolock_mount(char *table_name, char *host_data, - lm_callback_t cb, struct gfs2_sbd *sdp, + lm_callback_t cb, void *cb_data, unsigned int min_lvb_size, int flags, struct lm_lockstruct *lockstruct, struct kobject *fskobj) @@ -50,24 +50,24 @@ static int nolock_mount(char *table_name, char *host_data, lockstruct->ls_jid = jid; lockstruct->ls_first = 1; lockstruct->ls_lvb_size = min_lvb_size; - lockstruct->ls_lockspace = (lm_lockspace_t *)nl; + lockstruct->ls_lockspace = nl; lockstruct->ls_ops = &nolock_ops; lockstruct->ls_flags = LM_LSFLAG_LOCAL; return 0; } -static void nolock_others_may_mount(lm_lockspace_t *lockspace) +static void nolock_others_may_mount(void *lockspace) { } -static void nolock_unmount(lm_lockspace_t *lockspace) +static void nolock_unmount(void *lockspace) { - struct nolock_lockspace *nl = (struct nolock_lockspace *)lockspace; + struct nolock_lockspace *nl = lockspace; kfree(nl); } -static void nolock_withdraw(lm_lockspace_t *lockspace) +static void nolock_withdraw(void *lockspace) { } @@ -80,10 +80,10 @@ static void nolock_withdraw(lm_lockspace_t *lockspace) * Returns: 0 on success, -EXXX on failure */ -static int nolock_get_lock(lm_lockspace_t *lockspace, struct lm_lockname *name, - lm_lock_t **lockp) +static int nolock_get_lock(void *lockspace, struct lm_lockname *name, + void **lockp) { - *lockp = (lm_lock_t *)lockspace; + *lockp = lockspace; return 0; } @@ -93,7 +93,7 @@ static int nolock_get_lock(lm_lockspace_t *lockspace, struct lm_lockname *name, * */ -static void nolock_put_lock(lm_lock_t *lock) +static void nolock_put_lock(void *lock) { } @@ -107,7 +107,7 @@ static void nolock_put_lock(lm_lock_t *lock) * Returns: A bitmap of LM_OUT_* */ -static unsigned int nolock_lock(lm_lock_t *lock, unsigned int cur_state, +static unsigned int nolock_lock(void *lock, unsigned int cur_state, unsigned int req_state, unsigned int flags) { return req_state | LM_OUT_CACHEABLE; @@ -121,12 +121,12 @@ static unsigned int nolock_lock(lm_lock_t *lock, unsigned int cur_state, * Returns: 0 */ -static unsigned int nolock_unlock(lm_lock_t *lock, unsigned int cur_state) +static unsigned int nolock_unlock(void *lock, unsigned int cur_state) { return 0; } -static void nolock_cancel(lm_lock_t *lock) +static void nolock_cancel(void *lock) { } @@ -138,9 +138,9 @@ static void nolock_cancel(lm_lock_t *lock) * Returns: 0 on success, -EXXX on failure */ -static int nolock_hold_lvb(lm_lock_t *lock, char **lvbp) +static int nolock_hold_lvb(void *lock, char **lvbp) { - struct nolock_lockspace *nl = (struct nolock_lockspace *)lock; + struct nolock_lockspace *nl = lock; int error = 0; *lvbp = kzalloc(nl->nl_lvb_size, GFP_KERNEL); @@ -157,12 +157,12 @@ static int nolock_hold_lvb(lm_lock_t *lock, char **lvbp) * */ -static void nolock_unhold_lvb(lm_lock_t *lock, char *lvb) +static void nolock_unhold_lvb(void *lock, char *lvb) { kfree(lvb); } -static int nolock_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name, +static int nolock_plock_get(void *lockspace, struct lm_lockname *name, struct file *file, struct file_lock *fl) { struct file_lock tmp; @@ -176,7 +176,7 @@ static int nolock_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name, return 0; } -static int nolock_plock(lm_lockspace_t *lockspace, struct lm_lockname *name, +static int nolock_plock(void *lockspace, struct lm_lockname *name, struct file *file, int cmd, struct file_lock *fl) { int error; @@ -184,7 +184,7 @@ static int nolock_plock(lm_lockspace_t *lockspace, struct lm_lockname *name, return error; } -static int nolock_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name, +static int nolock_punlock(void *lockspace, struct lm_lockname *name, struct file *file, struct file_lock *fl) { int error; @@ -192,12 +192,12 @@ static int nolock_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name, return error; } -static void nolock_recovery_done(lm_lockspace_t *lockspace, unsigned int jid, +static void nolock_recovery_done(void *lockspace, unsigned int jid, unsigned int message) { } -static struct lm_lockops nolock_ops = { +static const struct lm_lockops nolock_ops = { .lm_proto_name = "lock_nolock", .lm_mount = nolock_mount, .lm_others_may_mount = nolock_others_may_mount, -- cgit 1.2.3-korg From 37b2fa6a24f996d751dc80fbc8a77602cead269b Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Fri, 8 Sep 2006 13:35:56 -0400 Subject: [GFS2] Move rwlocks in glock.c into their own array This splits the rwlocks guarding the hash chains of the glock hash table into their own array. This will reduce memory usage in some cases due to better alignment, although the real reason for doing it is to allow the two tables to be different sizes in future (i.e. the locks will be sized proportionally with the max number of CPUs and the hash chains sized proportinally with the size of physical memory) In order to allow this, the gl_bucket member of struct gfs2_glock has now become gl_hash, so we record the hash rather than a pointer to the bucket itself. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 87 +++++++++++++++++++++++++++----------------------------- fs/gfs2/incore.h | 7 +---- 2 files changed, 43 insertions(+), 51 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 92aa0e8c90992d..49512696160e0a 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -44,12 +44,17 @@ struct greedy { struct work_struct gr_work; }; +struct gfs2_gl_hash_bucket { + struct list_head hb_list; +}; + typedef void (*glock_examiner) (struct gfs2_glock * gl); static int gfs2_dump_lockstate(struct gfs2_sbd *sdp); static int dump_glock(struct gfs2_glock *gl); static struct gfs2_gl_hash_bucket gl_hash_table[GFS2_GL_HASH_SIZE]; +static rwlock_t gl_hash_locks[GFS2_GL_HASH_SIZE]; /** * relaxed_state_ok - is a requested lock compatible with the current lock mode? @@ -154,19 +159,18 @@ static void kill_glock(struct kref *kref) int gfs2_glock_put(struct gfs2_glock *gl) { - struct gfs2_gl_hash_bucket *bucket = gl->gl_bucket; int rv = 0; - write_lock(&bucket->hb_lock); + write_lock(&gl_hash_locks[gl->gl_hash]); if (kref_put(&gl->gl_ref, kill_glock)) { - list_del_init(&gl->gl_list); - write_unlock(&bucket->hb_lock); + list_del_init(&gl_hash_table[gl->gl_hash].hb_list); + write_unlock(&gl_hash_locks[gl->gl_hash]); BUG_ON(spin_is_locked(&gl->gl_spin)); glock_free(gl); rv = 1; goto out; } - write_unlock(&bucket->hb_lock); + write_unlock(&gl_hash_locks[gl->gl_hash]); out: return rv; } @@ -203,13 +207,13 @@ static inline int queue_empty(struct gfs2_glock *gl, struct list_head *head) * Returns: NULL, or the struct gfs2_glock with the requested number */ -static struct gfs2_glock *search_bucket(struct gfs2_gl_hash_bucket *bucket, +static struct gfs2_glock *search_bucket(unsigned int hash, const struct gfs2_sbd *sdp, const struct lm_lockname *name) { struct gfs2_glock *gl; - list_for_each_entry(gl, &bucket->hb_list, gl_list) { + list_for_each_entry(gl, &gl_hash_table[hash].hb_list, gl_list) { if (test_bit(GLF_PLUG, &gl->gl_flags)) continue; if (!lm_name_equal(&gl->gl_name, name)) @@ -236,12 +240,12 @@ static struct gfs2_glock *search_bucket(struct gfs2_gl_hash_bucket *bucket, static struct gfs2_glock *gfs2_glock_find(const struct gfs2_sbd *sdp, const struct lm_lockname *name) { - struct gfs2_gl_hash_bucket *bucket = &gl_hash_table[gl_hash(sdp, name)]; + unsigned int hash = gl_hash(sdp, name); struct gfs2_glock *gl; - read_lock(&bucket->hb_lock); - gl = search_bucket(bucket, sdp, name); - read_unlock(&bucket->hb_lock); + read_lock(&gl_hash_locks[hash]); + gl = search_bucket(hash, sdp, name); + read_unlock(&gl_hash_locks[hash]); return gl; } @@ -263,18 +267,14 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, const struct gfs2_glock_operations *glops, int create, struct gfs2_glock **glp) { - struct lm_lockname name; + struct lm_lockname name = { .ln_number = number, .ln_type = glops->go_type }; struct gfs2_glock *gl, *tmp; - struct gfs2_gl_hash_bucket *bucket; + unsigned int hash = gl_hash(sdp, &name); int error; - name.ln_number = number; - name.ln_type = glops->go_type; - bucket = &gl_hash_table[gl_hash(sdp, &name)]; - - read_lock(&bucket->hb_lock); - gl = search_bucket(bucket, sdp, &name); - read_unlock(&bucket->hb_lock); + read_lock(&gl_hash_locks[hash]); + gl = search_bucket(hash, sdp, &name); + read_unlock(&gl_hash_locks[hash]); if (gl || !create) { *glp = gl; @@ -289,6 +289,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, gl->gl_name = name; kref_init(&gl->gl_ref); gl->gl_state = LM_ST_UNLOCKED; + gl->gl_hash = hash; gl->gl_owner = NULL; gl->gl_ip = 0; gl->gl_ops = glops; @@ -297,7 +298,6 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, gl->gl_vn = 0; gl->gl_stamp = jiffies; gl->gl_object = NULL; - gl->gl_bucket = bucket; gl->gl_sbd = sdp; gl->gl_aspace = NULL; lops_init_le(&gl->gl_le, &gfs2_glock_lops); @@ -316,15 +316,15 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, if (error) goto fail_aspace; - write_lock(&bucket->hb_lock); - tmp = search_bucket(bucket, sdp, &name); + write_lock(&gl_hash_locks[hash]); + tmp = search_bucket(hash, sdp, &name); if (tmp) { - write_unlock(&bucket->hb_lock); + write_unlock(&gl_hash_locks[hash]); glock_free(gl); gl = tmp; } else { - list_add_tail(&gl->gl_list, &bucket->hb_list); - write_unlock(&bucket->hb_lock); + list_add_tail(&gl->gl_list, &gl_hash_table[hash].hb_list); + write_unlock(&gl_hash_locks[hash]); } *glp = gl; @@ -1868,7 +1868,7 @@ void gfs2_reclaim_glock(struct gfs2_sbd *sdp) */ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, - struct gfs2_gl_hash_bucket *bucket) + unsigned int hash) { struct glock_plug plug; struct list_head *tmp; @@ -1879,20 +1879,20 @@ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, memset(&plug.gl_flags, 0, sizeof(unsigned long)); set_bit(GLF_PLUG, &plug.gl_flags); - write_lock(&bucket->hb_lock); - list_add(&plug.gl_list, &bucket->hb_list); - write_unlock(&bucket->hb_lock); + write_lock(&gl_hash_locks[hash]); + list_add(&plug.gl_list, &gl_hash_table[hash].hb_list); + write_unlock(&gl_hash_locks[hash]); for (;;) { - write_lock(&bucket->hb_lock); + write_lock(&gl_hash_locks[hash]); for (;;) { tmp = plug.gl_list.next; - if (tmp == &bucket->hb_list) { + if (tmp == &gl_hash_table[hash].hb_list) { list_del(&plug.gl_list); - entries = !list_empty(&bucket->hb_list); - write_unlock(&bucket->hb_lock); + entries = !list_empty(&gl_hash_table[hash].hb_list); + write_unlock(&gl_hash_locks[hash]); return entries; } gl = list_entry(tmp, struct gfs2_glock, gl_list); @@ -1911,7 +1911,7 @@ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, break; } - write_unlock(&bucket->hb_lock); + write_unlock(&gl_hash_locks[hash]); examiner(gl); } @@ -1956,7 +1956,7 @@ void gfs2_scand_internal(struct gfs2_sbd *sdp) unsigned int x; for (x = 0; x < GFS2_GL_HASH_SIZE; x++) { - examine_bucket(scan_glock, sdp, &gl_hash_table[x]); + examine_bucket(scan_glock, sdp, x); cond_resched(); } } @@ -2015,7 +2015,7 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait) cont = 0; for (x = 0; x < GFS2_GL_HASH_SIZE; x++) - if (examine_bucket(clear_glock, sdp, &gl_hash_table[x])) + if (examine_bucket(clear_glock, sdp, x)) cont = 1; if (!wait || !cont) @@ -2198,17 +2198,15 @@ out: static int gfs2_dump_lockstate(struct gfs2_sbd *sdp) { - struct gfs2_gl_hash_bucket *bucket; struct gfs2_glock *gl; unsigned int x; int error = 0; for (x = 0; x < GFS2_GL_HASH_SIZE; x++) { - bucket = &gl_hash_table[x]; - read_lock(&bucket->hb_lock); + read_lock(&gl_hash_locks[x]); - list_for_each_entry(gl, &bucket->hb_list, gl_list) { + list_for_each_entry(gl, &gl_hash_table[x].hb_list, gl_list) { if (test_bit(GLF_PLUG, &gl->gl_flags)) continue; if (gl->gl_sbd != sdp) @@ -2219,7 +2217,7 @@ static int gfs2_dump_lockstate(struct gfs2_sbd *sdp) break; } - read_unlock(&bucket->hb_lock); + read_unlock(&gl_hash_locks[x]); if (error) break; @@ -2233,9 +2231,8 @@ int __init gfs2_glock_init(void) { unsigned i; for(i = 0; i < GFS2_GL_HASH_SIZE; i++) { - struct gfs2_gl_hash_bucket *hb = &gl_hash_table[i]; - rwlock_init(&hb->hb_lock); - INIT_LIST_HEAD(&hb->hb_list); + rwlock_init(&gl_hash_locks[i]); + INIT_LIST_HEAD(&gl_hash_table[i].hb_list); } return 0; } diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 9f5d98ff823ab9..f50ea6282e7753 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -106,11 +106,6 @@ struct gfs2_bufdata { struct list_head bd_ail_gl_list; }; -struct gfs2_gl_hash_bucket { - rwlock_t hb_lock; - struct list_head hb_list; -}; - struct gfs2_glock_operations { void (*go_xmote_th) (struct gfs2_glock * gl, unsigned int state, int flags); @@ -175,6 +170,7 @@ struct gfs2_glock { spinlock_t gl_spin; unsigned int gl_state; + unsigned int gl_hash; struct task_struct *gl_owner; unsigned long gl_ip; struct list_head gl_holders; @@ -195,7 +191,6 @@ struct gfs2_glock { unsigned long gl_stamp; void *gl_object; - struct gfs2_gl_hash_bucket *gl_bucket; struct list_head gl_reclaim; struct gfs2_sbd *gl_sbd; -- cgit 1.2.3-korg From 087efdd391f47305dc251a7b00dcc5d69e8c636a Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Sat, 9 Sep 2006 16:59:11 -0400 Subject: [GFS2] Make glock hash locks proportional to NR_CPUS Make the number of locks used for hash chains in glock.c proportional to NR_CPUS. Also move constants for the number of hash chains into glock.c from incore.h since they are not used outside of glock.c. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 93 ++++++++++++++++++++++++++++++++++++++++++++------------ fs/gfs2/incore.h | 3 -- 2 files changed, 74 insertions(+), 22 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 49512696160e0a..8abfefe4efd4a8 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -53,8 +53,59 @@ typedef void (*glock_examiner) (struct gfs2_glock * gl); static int gfs2_dump_lockstate(struct gfs2_sbd *sdp); static int dump_glock(struct gfs2_glock *gl); +#define GFS2_GL_HASH_SHIFT 13 +#define GFS2_GL_HASH_SIZE (1 << GFS2_GL_HASH_SHIFT) +#define GFS2_GL_HASH_MASK (GFS2_GL_HASH_SIZE - 1) + static struct gfs2_gl_hash_bucket gl_hash_table[GFS2_GL_HASH_SIZE]; -static rwlock_t gl_hash_locks[GFS2_GL_HASH_SIZE]; + +/* + * Despite what you might think, the numbers below are not arbitrary :-) + * They are taken from the ipv4 routing hash code, which is well tested + * and thus should be nearly optimal. Later on we might tweek the numbers + * but for now this should be fine. + * + * The reason for putting the locks in a separate array from the list heads + * is that we can have fewer locks than list heads and save memory. We use + * the same hash function for both, but with a different hash mask. + */ +#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) || \ + defined(CONFIG_PROVE_LOCKING) + +#ifdef CONFIG_LOCKDEP +# define GL_HASH_LOCK_SZ 256 +#else +# if NR_CPUS >= 32 +# define GL_HASH_LOCK_SZ 4096 +# elif NR_CPUS >= 16 +# define GL_HASH_LOCK_SZ 2048 +# elif NR_CPUS >= 8 +# define GL_HASH_LOCK_SZ 1024 +# elif NR_CPUS >= 4 +# define GL_HASH_LOCK_SZ 512 +# else +# define GL_HASH_LOCK_SZ 256 +# endif +#endif + +/* We never want more locks than chains */ +#if GFS2_GL_HASH_SIZE < GL_HASH_LOCK_SZ +# undef GL_HASH_LOCK_SZ +# define GL_HASH_LOCK_SZ GFS2_GL_HASH_SIZE +#endif + +static rwlock_t gl_hash_locks[GL_HASH_LOCK_SZ]; + +static inline rwlock_t *gl_lock_addr(unsigned int x) +{ + return &gl_hash_locks[(x) & (GL_HASH_LOCK_SZ-1)]; +} +#else /* not SMP, so no spinlocks required */ +static inline rwlock_t *gl_lock_addr(x) +{ + return NULL; +} +#endif /** * relaxed_state_ok - is a requested lock compatible with the current lock mode? @@ -161,16 +212,16 @@ int gfs2_glock_put(struct gfs2_glock *gl) { int rv = 0; - write_lock(&gl_hash_locks[gl->gl_hash]); + write_lock(gl_lock_addr(gl->gl_hash)); if (kref_put(&gl->gl_ref, kill_glock)) { list_del_init(&gl_hash_table[gl->gl_hash].hb_list); - write_unlock(&gl_hash_locks[gl->gl_hash]); + write_unlock(gl_lock_addr(gl->gl_hash)); BUG_ON(spin_is_locked(&gl->gl_spin)); glock_free(gl); rv = 1; goto out; } - write_unlock(&gl_hash_locks[gl->gl_hash]); + write_unlock(gl_lock_addr(gl->gl_hash)); out: return rv; } @@ -243,9 +294,9 @@ static struct gfs2_glock *gfs2_glock_find(const struct gfs2_sbd *sdp, unsigned int hash = gl_hash(sdp, name); struct gfs2_glock *gl; - read_lock(&gl_hash_locks[hash]); + read_lock(gl_lock_addr(hash)); gl = search_bucket(hash, sdp, name); - read_unlock(&gl_hash_locks[hash]); + read_unlock(gl_lock_addr(hash)); return gl; } @@ -272,9 +323,9 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, unsigned int hash = gl_hash(sdp, &name); int error; - read_lock(&gl_hash_locks[hash]); + read_lock(gl_lock_addr(hash)); gl = search_bucket(hash, sdp, &name); - read_unlock(&gl_hash_locks[hash]); + read_unlock(gl_lock_addr(hash)); if (gl || !create) { *glp = gl; @@ -316,15 +367,15 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, if (error) goto fail_aspace; - write_lock(&gl_hash_locks[hash]); + write_lock(gl_lock_addr(hash)); tmp = search_bucket(hash, sdp, &name); if (tmp) { - write_unlock(&gl_hash_locks[hash]); + write_unlock(gl_lock_addr(hash)); glock_free(gl); gl = tmp; } else { list_add_tail(&gl->gl_list, &gl_hash_table[hash].hb_list); - write_unlock(&gl_hash_locks[hash]); + write_unlock(gl_lock_addr(hash)); } *glp = gl; @@ -1879,12 +1930,12 @@ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, memset(&plug.gl_flags, 0, sizeof(unsigned long)); set_bit(GLF_PLUG, &plug.gl_flags); - write_lock(&gl_hash_locks[hash]); + write_lock(gl_lock_addr(hash)); list_add(&plug.gl_list, &gl_hash_table[hash].hb_list); - write_unlock(&gl_hash_locks[hash]); + write_unlock(gl_lock_addr(hash)); for (;;) { - write_lock(&gl_hash_locks[hash]); + write_lock(gl_lock_addr(hash)); for (;;) { tmp = plug.gl_list.next; @@ -1892,7 +1943,7 @@ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, if (tmp == &gl_hash_table[hash].hb_list) { list_del(&plug.gl_list); entries = !list_empty(&gl_hash_table[hash].hb_list); - write_unlock(&gl_hash_locks[hash]); + write_unlock(gl_lock_addr(hash)); return entries; } gl = list_entry(tmp, struct gfs2_glock, gl_list); @@ -1911,7 +1962,7 @@ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, break; } - write_unlock(&gl_hash_locks[hash]); + write_unlock(gl_lock_addr(hash)); examiner(gl); } @@ -2204,7 +2255,7 @@ static int gfs2_dump_lockstate(struct gfs2_sbd *sdp) for (x = 0; x < GFS2_GL_HASH_SIZE; x++) { - read_lock(&gl_hash_locks[x]); + read_lock(gl_lock_addr(x)); list_for_each_entry(gl, &gl_hash_table[x].hb_list, gl_list) { if (test_bit(GLF_PLUG, &gl->gl_flags)) @@ -2217,7 +2268,7 @@ static int gfs2_dump_lockstate(struct gfs2_sbd *sdp) break; } - read_unlock(&gl_hash_locks[x]); + read_unlock(gl_lock_addr(x)); if (error) break; @@ -2231,9 +2282,13 @@ int __init gfs2_glock_init(void) { unsigned i; for(i = 0; i < GFS2_GL_HASH_SIZE; i++) { - rwlock_init(&gl_hash_locks[i]); INIT_LIST_HEAD(&gl_hash_table[i].hb_list); } +#ifdef GL_HASH_LOCK_SZ + for(i = 0; i < GL_HASH_LOCK_SZ; i++) { + rwlock_init(&gl_hash_locks[i]); + } +#endif return 0; } diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index f50ea6282e7753..64e13435ca3ba0 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -448,9 +448,6 @@ enum { SDF_NOATIME = 3, }; -#define GFS2_GL_HASH_SHIFT 13 -#define GFS2_GL_HASH_SIZE (1 << GFS2_GL_HASH_SHIFT) -#define GFS2_GL_HASH_MASK (GFS2_GL_HASH_SIZE - 1) #define GFS2_FSNAME_LEN 256 struct gfs2_sbd { -- cgit 1.2.3-korg From a5e08a9ef50e8b6feb099f8e4b253df04f5ec9db Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Sat, 9 Sep 2006 17:07:05 -0400 Subject: [GFS2] Add consts to glock sorting function Add back the consts which were casted away in the glock sorting function. Also add early exit code. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 8abfefe4efd4a8..e941183bbcdb2a 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1494,26 +1494,20 @@ int gfs2_glock_nq_num(struct gfs2_sbd *sdp, u64 number, static int glock_compare(const void *arg_a, const void *arg_b) { - struct gfs2_holder *gh_a = *(struct gfs2_holder **)arg_a; - struct gfs2_holder *gh_b = *(struct gfs2_holder **)arg_b; - struct lm_lockname *a = &gh_a->gh_gl->gl_name; - struct lm_lockname *b = &gh_b->gh_gl->gl_name; - int ret = 0; + const struct gfs2_holder *gh_a = *(const struct gfs2_holder **)arg_a; + const struct gfs2_holder *gh_b = *(const struct gfs2_holder **)arg_b; + const struct lm_lockname *a = &gh_a->gh_gl->gl_name; + const struct lm_lockname *b = &gh_b->gh_gl->gl_name; if (a->ln_number > b->ln_number) - ret = 1; - else if (a->ln_number < b->ln_number) - ret = -1; - else { - if (gh_a->gh_state == LM_ST_SHARED && - gh_b->gh_state == LM_ST_EXCLUSIVE) - ret = 1; - else if (!(gh_a->gh_flags & GL_LOCAL_EXCL) && - (gh_b->gh_flags & GL_LOCAL_EXCL)) - ret = 1; - } - - return ret; + return 1; + if (a->ln_number < b->ln_number) + return -1; + if (gh_a->gh_state == LM_ST_SHARED && gh_b->gh_state == LM_ST_EXCLUSIVE) + return 1; + if (!(gh_a->gh_flags & GL_LOCAL_EXCL) && (gh_b->gh_flags & GL_LOCAL_EXCL)) + return 1; + return 0; } /** -- cgit 1.2.3-korg From 94610610f10749c0e17b4d2840ff8a7cb636c413 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Sat, 9 Sep 2006 18:59:27 -0400 Subject: [GFS2] Remove unused function from glock.c The callback for iopen locks is unused, so this removes it. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 22 ++-------------------- fs/gfs2/glock.h | 2 -- fs/gfs2/glops.c | 1 - 3 files changed, 2 insertions(+), 23 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index e941183bbcdb2a..b348053c436351 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -98,7 +98,7 @@ static rwlock_t gl_hash_locks[GL_HASH_LOCK_SZ]; static inline rwlock_t *gl_lock_addr(unsigned int x) { - return &gl_hash_locks[(x) & (GL_HASH_LOCK_SZ-1)]; + return &gl_hash_locks[x & (GL_HASH_LOCK_SZ-1)]; } #else /* not SMP, so no spinlocks required */ static inline rwlock_t *gl_lock_addr(x) @@ -1805,22 +1805,6 @@ void gfs2_glock_cb(void *cb_data, unsigned int type, void *data) } } -/** - * gfs2_iopen_go_callback - Try to kick the inode/vnode associated with an - * iopen glock from memory - * @io_gl: the iopen glock - * @state: the state into which the glock should be put - * - */ - -void gfs2_iopen_go_callback(struct gfs2_glock *io_gl, unsigned int state) -{ - - if (state != LM_ST_UNLOCKED) - return; - /* FIXME: remove this? */ -} - /** * demote_ok - Check to see if it's ok to unlock a glock * @gl: the glock @@ -2000,10 +1984,8 @@ void gfs2_scand_internal(struct gfs2_sbd *sdp) { unsigned int x; - for (x = 0; x < GFS2_GL_HASH_SIZE; x++) { + for (x = 0; x < GFS2_GL_HASH_SIZE; x++) examine_bucket(scan_glock, sdp, x); - cond_resched(); - } } /** diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 52b8a308635ab8..2b2a889ee2cc9b 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -142,8 +142,6 @@ void gfs2_lvb_unhold(struct gfs2_glock *gl); void gfs2_glock_cb(void *cb_data, unsigned int type, void *data); -void gfs2_iopen_go_callback(struct gfs2_glock *gl, unsigned int state); - void gfs2_glock_schedule_for_reclaim(struct gfs2_glock *gl); void gfs2_reclaim_glock(struct gfs2_sbd *sdp); diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 0c50a720d01d6c..d3aef74ea5d4a6 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -529,7 +529,6 @@ const struct gfs2_glock_operations gfs2_trans_glops = { const struct gfs2_glock_operations gfs2_iopen_glops = { .go_xmote_th = gfs2_glock_xmote_th, .go_drop_th = gfs2_glock_drop_th, - .go_callback = gfs2_iopen_go_callback, .go_type = LM_TYPE_IOPEN, }; -- cgit 1.2.3-korg From 24264434603cc102d71fb2a1b3b7e282a781f449 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Mon, 11 Sep 2006 21:40:30 -0400 Subject: [GFS2] Rewrite of examine_bucket() The existing implementation of this function in glock.c was not very efficient as it relied upon keeping a cursor element upon the hash chain in question and moving it along. This new version improves upon this by using the current element as a cursor. This is possible since we only look at the "next" element in the list after we've taken the read_lock() subsequent to calling the examiner function. Obviously we have to eventually drop the ref count that we are then left with and we cannot do that while holding the read_lock, so we do that next time we drop the lock. That means either just before we examine another glock, or when the loop has terminated. The new implementation has several advantages: it uses only a read_lock() rather than a write_lock(), so it can run simnultaneously with other code, it doesn't need a "plug" element, so that it removes a test not only from this list iterator, but from all the other glock list iterators too. So it makes things faster and smaller. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 95 ++++++++++++++++++-------------------------------------- fs/gfs2/incore.h | 1 - 2 files changed, 31 insertions(+), 65 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index b348053c436351..b5effb9e4a385d 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "gfs2.h" @@ -33,12 +34,6 @@ #include "super.h" #include "util.h" -/* Must be kept in sync with the beginning of struct gfs2_glock */ -struct glock_plug { - struct list_head gl_list; - unsigned long gl_flags; -}; - struct greedy { struct gfs2_holder gr_gh; struct work_struct gr_work; @@ -52,6 +47,7 @@ typedef void (*glock_examiner) (struct gfs2_glock * gl); static int gfs2_dump_lockstate(struct gfs2_sbd *sdp); static int dump_glock(struct gfs2_glock *gl); +static int dump_inode(struct gfs2_inode *ip); #define GFS2_GL_HASH_SHIFT 13 #define GFS2_GL_HASH_SIZE (1 << GFS2_GL_HASH_SHIFT) @@ -214,7 +210,7 @@ int gfs2_glock_put(struct gfs2_glock *gl) write_lock(gl_lock_addr(gl->gl_hash)); if (kref_put(&gl->gl_ref, kill_glock)) { - list_del_init(&gl_hash_table[gl->gl_hash].hb_list); + list_del_init(&gl->gl_list); write_unlock(gl_lock_addr(gl->gl_hash)); BUG_ON(spin_is_locked(&gl->gl_spin)); glock_free(gl); @@ -265,8 +261,6 @@ static struct gfs2_glock *search_bucket(unsigned int hash, struct gfs2_glock *gl; list_for_each_entry(gl, &gl_hash_table[hash].hb_list, gl_list) { - if (test_bit(GLF_PLUG, &gl->gl_flags)) - continue; if (!lm_name_equal(&gl->gl_name, name)) continue; if (gl->gl_sbd != sdp) @@ -1899,51 +1893,33 @@ void gfs2_reclaim_glock(struct gfs2_sbd *sdp) static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, unsigned int hash) { - struct glock_plug plug; - struct list_head *tmp; - struct gfs2_glock *gl; - int entries; - - /* Add "plug" to end of bucket list, work back up list from there */ - memset(&plug.gl_flags, 0, sizeof(unsigned long)); - set_bit(GLF_PLUG, &plug.gl_flags); - - write_lock(gl_lock_addr(hash)); - list_add(&plug.gl_list, &gl_hash_table[hash].hb_list); - write_unlock(gl_lock_addr(hash)); - - for (;;) { - write_lock(gl_lock_addr(hash)); - - for (;;) { - tmp = plug.gl_list.next; + struct gfs2_glock *gl, *prev = NULL; + int has_entries = 0; + struct list_head *head = &gl_hash_table[hash].hb_list; - if (tmp == &gl_hash_table[hash].hb_list) { - list_del(&plug.gl_list); - entries = !list_empty(&gl_hash_table[hash].hb_list); - write_unlock(gl_lock_addr(hash)); - return entries; - } - gl = list_entry(tmp, struct gfs2_glock, gl_list); - - /* Move plug up list */ - list_move(&plug.gl_list, &gl->gl_list); - - if (test_bit(GLF_PLUG, &gl->gl_flags)) - continue; - if (gl->gl_sbd != sdp) - continue; - - /* examiner() must glock_put() */ + read_lock(gl_lock_addr(hash)); + /* Can't use list_for_each_entry - don't want prefetch here */ + if (list_empty(head)) + goto out; + has_entries = 1; + gl = list_entry(head->next, struct gfs2_glock, gl_list); + while(&gl->gl_list != head) { + if (gl->gl_sbd == sdp) { gfs2_glock_hold(gl); - - break; + read_unlock(gl_lock_addr(hash)); + if (prev) + gfs2_glock_put(prev); + prev = gl; + examiner(gl); + read_lock(gl_lock_addr(hash)); } - - write_unlock(gl_lock_addr(hash)); - - examiner(gl); + gl = list_entry(gl->gl_list.next, struct gfs2_glock, gl_list); } +out: + read_unlock(gl_lock_addr(hash)); + if (prev) + gfs2_glock_put(prev); + return has_entries; } /** @@ -1955,23 +1931,19 @@ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, static void scan_glock(struct gfs2_glock *gl) { if (gl->gl_ops == &gfs2_inode_glops) - goto out; + return; if (gfs2_glmutex_trylock(gl)) { if (queue_empty(gl, &gl->gl_holders) && - gl->gl_state != LM_ST_UNLOCKED && - demote_ok(gl)) + gl->gl_state != LM_ST_UNLOCKED && demote_ok(gl)) goto out_schedule; gfs2_glmutex_unlock(gl); } -out: - gfs2_glock_put(gl); return; out_schedule: gfs2_glmutex_unlock(gl); gfs2_glock_schedule_for_reclaim(gl); - gfs2_glock_put(gl); } /** @@ -2014,11 +1986,8 @@ static void clear_glock(struct gfs2_glock *gl) if (queue_empty(gl, &gl->gl_holders) && gl->gl_state != LM_ST_UNLOCKED) handle_callback(gl, LM_ST_UNLOCKED); - gfs2_glmutex_unlock(gl); } - - gfs2_glock_put(gl); } /** @@ -2040,10 +2009,10 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait) for (;;) { cont = 0; - - for (x = 0; x < GFS2_GL_HASH_SIZE; x++) - if (examine_bucket(clear_glock, sdp, x)) + for (x = 0; x < GFS2_GL_HASH_SIZE; x++) { + if (examine_bucket(clear_glock, sdp, x)) cont = 1; + } if (!wait || !cont) break; @@ -2234,8 +2203,6 @@ static int gfs2_dump_lockstate(struct gfs2_sbd *sdp) read_lock(gl_lock_addr(x)); list_for_each_entry(gl, &gl_hash_table[x].hb_list, gl_list) { - if (test_bit(GLF_PLUG, &gl->gl_flags)) - continue; if (gl->gl_sbd != sdp) continue; diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 64e13435ca3ba0..1fed8d1abae579 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -152,7 +152,6 @@ struct gfs2_holder { }; enum { - GLF_PLUG = 0, GLF_LOCK = 1, GLF_STICKY = 2, GLF_PREFETCH = 3, -- cgit 1.2.3-korg From b6397893a5ed81970e803d61ee2f1a0e79f87438 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Tue, 12 Sep 2006 10:10:01 -0400 Subject: [GFS2] Use hlist for glock hash chains This results in smaller list heads, so that we can have more chains in the same amount of memory (twice as many). I've multiplied the size of the table by four though - this is because we are saving memory by not having one lock per chain any more. So we land up using about the same amount of memory for the hash table as we did before I started these changes, the difference being that we now have four times as many hash chains. The reason that I say "about the same amount of memory" is that the actual amount now depends upon the NR_CPUS and some of the config variables, so that its not exact and in some cases we do use more memory. Eventually we might want to scale the hash table size according to the size of physical ram as measured on module load. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 28 ++++++++++++++++------------ fs/gfs2/incore.h | 2 +- fs/gfs2/main.c | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index b5effb9e4a385d..cf54b0b001fdc3 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -40,7 +40,7 @@ struct greedy { }; struct gfs2_gl_hash_bucket { - struct list_head hb_list; + struct hlist_head hb_list; }; typedef void (*glock_examiner) (struct gfs2_glock * gl); @@ -49,7 +49,7 @@ static int gfs2_dump_lockstate(struct gfs2_sbd *sdp); static int dump_glock(struct gfs2_glock *gl); static int dump_inode(struct gfs2_inode *ip); -#define GFS2_GL_HASH_SHIFT 13 +#define GFS2_GL_HASH_SHIFT 15 #define GFS2_GL_HASH_SIZE (1 << GFS2_GL_HASH_SHIFT) #define GFS2_GL_HASH_MASK (GFS2_GL_HASH_SIZE - 1) @@ -210,7 +210,7 @@ int gfs2_glock_put(struct gfs2_glock *gl) write_lock(gl_lock_addr(gl->gl_hash)); if (kref_put(&gl->gl_ref, kill_glock)) { - list_del_init(&gl->gl_list); + hlist_del(&gl->gl_list); write_unlock(gl_lock_addr(gl->gl_hash)); BUG_ON(spin_is_locked(&gl->gl_spin)); glock_free(gl); @@ -259,8 +259,9 @@ static struct gfs2_glock *search_bucket(unsigned int hash, const struct lm_lockname *name) { struct gfs2_glock *gl; + struct hlist_node *h; - list_for_each_entry(gl, &gl_hash_table[hash].hb_list, gl_list) { + hlist_for_each_entry(gl, h, &gl_hash_table[hash].hb_list, gl_list) { if (!lm_name_equal(&gl->gl_name, name)) continue; if (gl->gl_sbd != sdp) @@ -368,7 +369,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, glock_free(gl); gl = tmp; } else { - list_add_tail(&gl->gl_list, &gl_hash_table[hash].hb_list); + hlist_add_head(&gl->gl_list, &gl_hash_table[hash].hb_list); write_unlock(gl_lock_addr(hash)); } @@ -1895,15 +1896,15 @@ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, { struct gfs2_glock *gl, *prev = NULL; int has_entries = 0; - struct list_head *head = &gl_hash_table[hash].hb_list; + struct hlist_head *head = &gl_hash_table[hash].hb_list; read_lock(gl_lock_addr(hash)); - /* Can't use list_for_each_entry - don't want prefetch here */ - if (list_empty(head)) + /* Can't use hlist_for_each_entry - don't want prefetch here */ + if (hlist_empty(head)) goto out; has_entries = 1; - gl = list_entry(head->next, struct gfs2_glock, gl_list); - while(&gl->gl_list != head) { + gl = list_entry(head->first, struct gfs2_glock, gl_list); + while(1) { if (gl->gl_sbd == sdp) { gfs2_glock_hold(gl); read_unlock(gl_lock_addr(hash)); @@ -1913,6 +1914,8 @@ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, examiner(gl); read_lock(gl_lock_addr(hash)); } + if (gl->gl_list.next == NULL) + break; gl = list_entry(gl->gl_list.next, struct gfs2_glock, gl_list); } out: @@ -2195,6 +2198,7 @@ out: static int gfs2_dump_lockstate(struct gfs2_sbd *sdp) { struct gfs2_glock *gl; + struct hlist_node *h; unsigned int x; int error = 0; @@ -2202,7 +2206,7 @@ static int gfs2_dump_lockstate(struct gfs2_sbd *sdp) read_lock(gl_lock_addr(x)); - list_for_each_entry(gl, &gl_hash_table[x].hb_list, gl_list) { + hlist_for_each_entry(gl, h, &gl_hash_table[x].hb_list, gl_list) { if (gl->gl_sbd != sdp) continue; @@ -2225,7 +2229,7 @@ int __init gfs2_glock_init(void) { unsigned i; for(i = 0; i < GFS2_GL_HASH_SIZE; i++) { - INIT_LIST_HEAD(&gl_hash_table[i].hb_list); + INIT_HLIST_HEAD(&gl_hash_table[i].hb_list); } #ifdef GL_HASH_LOCK_SZ for(i = 0; i < GL_HASH_LOCK_SZ; i++) { diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 1fed8d1abae579..c68d39271edefb 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -161,7 +161,7 @@ enum { }; struct gfs2_glock { - struct list_head gl_list; + struct hlist_node gl_list; unsigned long gl_flags; /* GLF_... */ struct lm_lockname gl_name; struct kref gl_ref; diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index 2bdf246436c722..d2867988cc346b 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c @@ -42,7 +42,7 @@ static void gfs2_init_glock_once(void *foo, kmem_cache_t *cachep, unsigned long struct gfs2_glock *gl = foo; if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == SLAB_CTOR_CONSTRUCTOR) { - INIT_LIST_HEAD(&gl->gl_list); + INIT_HLIST_NODE(&gl->gl_list); spin_lock_init(&gl->gl_spin); INIT_LIST_HEAD(&gl->gl_holders); INIT_LIST_HEAD(&gl->gl_waiters1); -- cgit 1.2.3-korg From 16feb9fec0e1f74339bd6992130ceedb3aa9567e Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Wed, 13 Sep 2006 10:43:37 -0400 Subject: [GFS2] Use atomic_t rather than kref in glock.c Use atomic_t as the ref count in glocks rather than a kref. This is another step towards using RCU for the glock hash. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 34 ++++++++++++---------------------- fs/gfs2/incore.h | 2 +- 2 files changed, 13 insertions(+), 23 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index cf54b0b001fdc3..2316490723c045 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -179,23 +178,7 @@ static void glock_free(struct gfs2_glock *gl) void gfs2_glock_hold(struct gfs2_glock *gl) { - kref_get(&gl->gl_ref); -} - -/* All work is done after the return from kref_put() so we - can release the write_lock before the free. */ - -static void kill_glock(struct kref *kref) -{ - struct gfs2_glock *gl = container_of(kref, struct gfs2_glock, gl_ref); - struct gfs2_sbd *sdp = gl->gl_sbd; - - gfs2_assert(sdp, gl->gl_state == LM_ST_UNLOCKED); - gfs2_assert(sdp, list_empty(&gl->gl_reclaim)); - gfs2_assert(sdp, list_empty(&gl->gl_holders)); - gfs2_assert(sdp, list_empty(&gl->gl_waiters1)); - gfs2_assert(sdp, list_empty(&gl->gl_waiters2)); - gfs2_assert(sdp, list_empty(&gl->gl_waiters3)); + atomic_inc(&gl->gl_ref); } /** @@ -207,12 +190,19 @@ static void kill_glock(struct kref *kref) int gfs2_glock_put(struct gfs2_glock *gl) { int rv = 0; + struct gfs2_sbd *sdp = gl->gl_sbd; write_lock(gl_lock_addr(gl->gl_hash)); - if (kref_put(&gl->gl_ref, kill_glock)) { + if (atomic_dec_and_test(&gl->gl_ref)) { hlist_del(&gl->gl_list); write_unlock(gl_lock_addr(gl->gl_hash)); BUG_ON(spin_is_locked(&gl->gl_spin)); + gfs2_assert(sdp, gl->gl_state == LM_ST_UNLOCKED); + gfs2_assert(sdp, list_empty(&gl->gl_reclaim)); + gfs2_assert(sdp, list_empty(&gl->gl_holders)); + gfs2_assert(sdp, list_empty(&gl->gl_waiters1)); + gfs2_assert(sdp, list_empty(&gl->gl_waiters2)); + gfs2_assert(sdp, list_empty(&gl->gl_waiters3)); glock_free(gl); rv = 1; goto out; @@ -267,7 +257,7 @@ static struct gfs2_glock *search_bucket(unsigned int hash, if (gl->gl_sbd != sdp) continue; - kref_get(&gl->gl_ref); + atomic_inc(&gl->gl_ref); return gl; } @@ -333,7 +323,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, gl->gl_flags = 0; gl->gl_name = name; - kref_init(&gl->gl_ref); + atomic_set(&gl->gl_ref, 1); gl->gl_state = LM_ST_UNLOCKED; gl->gl_hash = hash; gl->gl_owner = NULL; @@ -2124,7 +2114,7 @@ static int dump_glock(struct gfs2_glock *gl) printk(" %u", x); } printk(" \n"); - printk(KERN_INFO " gl_ref = %d\n", atomic_read(&gl->gl_ref.refcount)); + printk(KERN_INFO " gl_ref = %d\n", atomic_read(&gl->gl_ref)); printk(KERN_INFO " gl_state = %u\n", gl->gl_state); printk(KERN_INFO " gl_owner = %s\n", gl->gl_owner->comm); print_symbol(KERN_INFO " gl_ip = %s\n", gl->gl_ip); diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index c68d39271edefb..89df68b32fc688 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -164,7 +164,7 @@ struct gfs2_glock { struct hlist_node gl_list; unsigned long gl_flags; /* GLF_... */ struct lm_lockname gl_name; - struct kref gl_ref; + atomic_t gl_ref; spinlock_t gl_spin; -- cgit 1.2.3-korg From a8336344a5fd1366eb3616d351c39cadcd077f43 Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Thu, 14 Sep 2006 13:57:38 -0400 Subject: [GFS2] Fix glock hash clearing A one liner bug fix to prevent the return value being wrong when more than one superblock is mounted. Signed-off-by: Steven Whitehouse --- fs/gfs2/glock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 2316490723c045..64a1676e5f48a4 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -1892,7 +1892,6 @@ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, /* Can't use hlist_for_each_entry - don't want prefetch here */ if (hlist_empty(head)) goto out; - has_entries = 1; gl = list_entry(head->first, struct gfs2_glock, gl_list); while(1) { if (gl->gl_sbd == sdp) { @@ -1902,6 +1901,7 @@ static int examine_bucket(glock_examiner examiner, struct gfs2_sbd *sdp, gfs2_glock_put(prev); prev = gl; examiner(gl); + has_entries = 1; read_lock(gl_lock_addr(hash)); } if (gl->gl_list.next == NULL) -- cgit 1.2.3-korg From 7d308590ae60d1f038a54a94e78a385c5c163452 Mon Sep 17 00:00:00 2001 From: Fabio Massimo Di Nitto Date: Tue, 19 Sep 2006 07:56:29 +0200 Subject: [GFS2] Export lm_interface to kernel headers lm_interface.h has a few out of the tree clients such as GFS1 and userland tools. Right now, these clients keeps a copy of the file in their build tree that can go out of sync. Move lm_interface.h to include/linux, export it to userland and clean up fs/gfs2 to use the new location. Signed-off-by: Fabio M. Di Nitto Signed-off-by: Steven Whitehouse --- fs/gfs2/acl.c | 2 +- fs/gfs2/bmap.c | 2 +- fs/gfs2/daemon.c | 2 +- fs/gfs2/dir.c | 2 +- fs/gfs2/eaops.c | 2 +- fs/gfs2/eattr.c | 2 +- fs/gfs2/glock.c | 2 +- fs/gfs2/glops.c | 2 +- fs/gfs2/inode.c | 2 +- fs/gfs2/lm.c | 2 +- fs/gfs2/lm_interface.h | 273 ----------------------------------------- fs/gfs2/locking.c | 3 +- fs/gfs2/locking/dlm/lock_dlm.h | 2 +- fs/gfs2/locking/nolock/main.c | 3 +- fs/gfs2/log.c | 2 +- fs/gfs2/lops.c | 2 +- fs/gfs2/main.c | 2 +- fs/gfs2/meta_io.c | 2 +- fs/gfs2/mount.c | 2 +- fs/gfs2/ops_address.c | 2 +- fs/gfs2/ops_dentry.c | 2 +- fs/gfs2/ops_export.c | 2 +- fs/gfs2/ops_file.c | 2 +- fs/gfs2/ops_fstype.c | 2 +- fs/gfs2/ops_inode.c | 2 +- fs/gfs2/ops_super.c | 2 +- fs/gfs2/ops_vm.c | 2 +- fs/gfs2/quota.c | 2 +- fs/gfs2/recovery.c | 2 +- fs/gfs2/rgrp.c | 2 +- fs/gfs2/super.c | 2 +- fs/gfs2/sys.c | 2 +- fs/gfs2/trans.c | 2 +- fs/gfs2/util.c | 2 +- include/linux/Kbuild | 6 +- include/linux/lm_interface.h | 273 +++++++++++++++++++++++++++++++++++++++++ 36 files changed, 309 insertions(+), 311 deletions(-) delete mode 100644 fs/gfs2/lm_interface.h create mode 100644 include/linux/lm_interface.h (limited to 'fs/gfs2/glock.c') diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index d846b5ad1d87f4..3123fc07123378 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c @@ -15,9 +15,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "acl.h" #include "eaops.h" diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index bd5bc887ef9b63..19b9bfc10349b0 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -14,9 +14,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "bmap.h" #include "glock.h" diff --git a/fs/gfs2/daemon.c b/fs/gfs2/daemon.c index a2a07c41845d41..a9908cd78cd948 100644 --- a/fs/gfs2/daemon.c +++ b/fs/gfs2/daemon.c @@ -15,9 +15,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "daemon.h" #include "glock.h" diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index f3dbda216caf70..7390286882702d 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -61,9 +61,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "dir.h" #include "glock.h" diff --git a/fs/gfs2/eaops.c b/fs/gfs2/eaops.c index adb898ceaa181c..1a7877fe73934c 100644 --- a/fs/gfs2/eaops.c +++ b/fs/gfs2/eaops.c @@ -14,10 +14,10 @@ #include #include #include +#include #include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "acl.h" #include "eaops.h" diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c index d7b92fba69987d..698942ec7c99f8 100644 --- a/fs/gfs2/eattr.c +++ b/fs/gfs2/eattr.c @@ -14,10 +14,10 @@ #include #include #include +#include #include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "acl.h" #include "eaops.h" diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 64a1676e5f48a4..f98694e7d6685f 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -18,10 +18,10 @@ #include #include #include +#include #include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "glock.h" #include "glops.h" diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index d3aef74ea5d4a6..9c046dbf472954 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -13,9 +13,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "bmap.h" #include "glock.h" diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 0d010f0654d917..b9e4bcb3bf1e18 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -16,9 +16,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "acl.h" #include "bmap.h" diff --git a/fs/gfs2/lm.c b/fs/gfs2/lm.c index 4e23aa5ef75d3b..2109fc4791d4b9 100644 --- a/fs/gfs2/lm.c +++ b/fs/gfs2/lm.c @@ -14,9 +14,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "glock.h" #include "lm.h" diff --git a/fs/gfs2/lm_interface.h b/fs/gfs2/lm_interface.h deleted file mode 100644 index 1418fdc9ac0261..00000000000000 --- a/fs/gfs2/lm_interface.h +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. - * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. - * - * This copyrighted material is made available to anyone wishing to use, - * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License version 2. - */ - -#ifndef __LM_INTERFACE_DOT_H__ -#define __LM_INTERFACE_DOT_H__ - - -typedef void (*lm_callback_t) (void *ptr, unsigned int type, void *data); - -/* - * lm_mount() flags - * - * LM_MFLAG_SPECTATOR - * GFS is asking to join the filesystem's lockspace, but it doesn't want to - * modify the filesystem. The lock module shouldn't assign a journal to the FS - * mount. It shouldn't send recovery callbacks to the FS mount. If the node - * dies or withdraws, all locks can be wiped immediately. - */ - -#define LM_MFLAG_SPECTATOR 0x00000001 - -/* - * lm_lockstruct flags - * - * LM_LSFLAG_LOCAL - * The lock_nolock module returns LM_LSFLAG_LOCAL to GFS, indicating that GFS - * can make single-node optimizations. - */ - -#define LM_LSFLAG_LOCAL 0x00000001 - -/* - * lm_lockname types - */ - -#define LM_TYPE_RESERVED 0x00 -#define LM_TYPE_NONDISK 0x01 -#define LM_TYPE_INODE 0x02 -#define LM_TYPE_RGRP 0x03 -#define LM_TYPE_META 0x04 -#define LM_TYPE_IOPEN 0x05 -#define LM_TYPE_FLOCK 0x06 -#define LM_TYPE_PLOCK 0x07 -#define LM_TYPE_QUOTA 0x08 -#define LM_TYPE_JOURNAL 0x09 - -/* - * lm_lock() states - * - * SHARED is compatible with SHARED, not with DEFERRED or EX. - * DEFERRED is compatible with DEFERRED, not with SHARED or EX. - */ - -#define LM_ST_UNLOCKED 0 -#define LM_ST_EXCLUSIVE 1 -#define LM_ST_DEFERRED 2 -#define LM_ST_SHARED 3 - -/* - * lm_lock() flags - * - * LM_FLAG_TRY - * Don't wait to acquire the lock if it can't be granted immediately. - * - * LM_FLAG_TRY_1CB - * Send one blocking callback if TRY is set and the lock is not granted. - * - * LM_FLAG_NOEXP - * GFS sets this flag on lock requests it makes while doing journal recovery. - * These special requests should not be blocked due to the recovery like - * ordinary locks would be. - * - * LM_FLAG_ANY - * A SHARED request may also be granted in DEFERRED, or a DEFERRED request may - * also be granted in SHARED. The preferred state is whichever is compatible - * with other granted locks, or the specified state if no other locks exist. - * - * LM_FLAG_PRIORITY - * Override fairness considerations. Suppose a lock is held in a shared state - * and there is a pending request for the deferred state. A shared lock - * request with the priority flag would be allowed to bypass the deferred - * request and directly join the other shared lock. A shared lock request - * without the priority flag might be forced to wait until the deferred - * requested had acquired and released the lock. - */ - -#define LM_FLAG_TRY 0x00000001 -#define LM_FLAG_TRY_1CB 0x00000002 -#define LM_FLAG_NOEXP 0x00000004 -#define LM_FLAG_ANY 0x00000008 -#define LM_FLAG_PRIORITY 0x00000010 - -/* - * lm_lock() and lm_async_cb return flags - * - * LM_OUT_ST_MASK - * Masks the lower two bits of lock state in the returned value. - * - * LM_OUT_CACHEABLE - * The lock hasn't been released so GFS can continue to cache data for it. - * - * LM_OUT_CANCELED - * The lock request was canceled. - * - * LM_OUT_ASYNC - * The result of the request will be returned in an LM_CB_ASYNC callback. - */ - -#define LM_OUT_ST_MASK 0x00000003 -#define LM_OUT_CACHEABLE 0x00000004 -#define LM_OUT_CANCELED 0x00000008 -#define LM_OUT_ASYNC 0x00000080 -#define LM_OUT_ERROR 0x00000100 - -/* - * lm_callback_t types - * - * LM_CB_NEED_E LM_CB_NEED_D LM_CB_NEED_S - * Blocking callback, a remote node is requesting the given lock in - * EXCLUSIVE, DEFERRED, or SHARED. - * - * LM_CB_NEED_RECOVERY - * The given journal needs to be recovered. - * - * LM_CB_DROPLOCKS - * Reduce the number of cached locks. - * - * LM_CB_ASYNC - * The given lock has been granted. - */ - -#define LM_CB_NEED_E 257 -#define LM_CB_NEED_D 258 -#define LM_CB_NEED_S 259 -#define LM_CB_NEED_RECOVERY 260 -#define LM_CB_DROPLOCKS 261 -#define LM_CB_ASYNC 262 - -/* - * lm_recovery_done() messages - */ - -#define LM_RD_GAVEUP 308 -#define LM_RD_SUCCESS 309 - - -struct lm_lockname { - u64 ln_number; - unsigned int ln_type; -}; - -#define lm_name_equal(name1, name2) \ - (((name1)->ln_number == (name2)->ln_number) && \ - ((name1)->ln_type == (name2)->ln_type)) \ - -struct lm_async_cb { - struct lm_lockname lc_name; - int lc_ret; -}; - -struct lm_lockstruct; - -struct lm_lockops { - const char *lm_proto_name; - - /* - * Mount/Unmount - */ - - int (*lm_mount) (char *table_name, char *host_data, - lm_callback_t cb, void *cb_data, - unsigned int min_lvb_size, int flags, - struct lm_lockstruct *lockstruct, - struct kobject *fskobj); - - void (*lm_others_may_mount) (void *lockspace); - - void (*lm_unmount) (void *lockspace); - - void (*lm_withdraw) (void *lockspace); - - /* - * Lock oriented operations - */ - - int (*lm_get_lock) (void *lockspace, struct lm_lockname *name, void **lockp); - - void (*lm_put_lock) (void *lock); - - unsigned int (*lm_lock) (void *lock, unsigned int cur_state, - unsigned int req_state, unsigned int flags); - - unsigned int (*lm_unlock) (void *lock, unsigned int cur_state); - - void (*lm_cancel) (void *lock); - - int (*lm_hold_lvb) (void *lock, char **lvbp); - void (*lm_unhold_lvb) (void *lock, char *lvb); - - /* - * Posix Lock oriented operations - */ - - int (*lm_plock_get) (void *lockspace, struct lm_lockname *name, - struct file *file, struct file_lock *fl); - - int (*lm_plock) (void *lockspace, struct lm_lockname *name, - struct file *file, int cmd, struct file_lock *fl); - - int (*lm_punlock) (void *lockspace, struct lm_lockname *name, - struct file *file, struct file_lock *fl); - - /* - * Client oriented operations - */ - - void (*lm_recovery_done) (void *lockspace, unsigned int jid, - unsigned int message); - - struct module *lm_owner; -}; - -/* - * lm_mount() return values - * - * ls_jid - the journal ID this node should use - * ls_first - this node is the first to mount the file system - * ls_lvb_size - size in bytes of lock value blocks - * ls_lockspace - lock module's context for this file system - * ls_ops - lock module's functions - * ls_flags - lock module features - */ - -struct lm_lockstruct { - unsigned int ls_jid; - unsigned int ls_first; - unsigned int ls_lvb_size; - void *ls_lockspace; - const struct lm_lockops *ls_ops; - int ls_flags; -}; - -/* - * Lock module bottom interface. A lock module makes itself available to GFS - * with these functions. - */ - -int gfs2_register_lockproto(const struct lm_lockops *proto); -void gfs2_unregister_lockproto(const struct lm_lockops *proto); - -/* - * Lock module top interface. GFS calls these functions when mounting or - * unmounting a file system. - */ - -int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data, - lm_callback_t cb, void *cb_data, - unsigned int min_lvb_size, int flags, - struct lm_lockstruct *lockstruct, - struct kobject *fskobj); - -void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct); - -void gfs2_withdraw_lockproto(struct lm_lockstruct *lockstruct); - -#endif /* __LM_INTERFACE_DOT_H__ */ - diff --git a/fs/gfs2/locking.c b/fs/gfs2/locking.c index 65eca48b2eae23..663fee7287832b 100644 --- a/fs/gfs2/locking.c +++ b/fs/gfs2/locking.c @@ -16,8 +16,7 @@ #include #include #include - -#include "lm_interface.h" +#include struct lmh_wrapper { struct list_head lw_list; diff --git a/fs/gfs2/locking/dlm/lock_dlm.h b/fs/gfs2/locking/dlm/lock_dlm.h index 3a45c020d01e31..33af707a4d3f39 100644 --- a/fs/gfs2/locking/dlm/lock_dlm.h +++ b/fs/gfs2/locking/dlm/lock_dlm.h @@ -26,7 +26,7 @@ #include #include -#include "../../lm_interface.h" +#include /* * Internally, we prefix things with gdlm_ and GDLM_ (for gfs-dlm) since a diff --git a/fs/gfs2/locking/nolock/main.c b/fs/gfs2/locking/nolock/main.c index 7b263fc6c27372..acfbc941f31950 100644 --- a/fs/gfs2/locking/nolock/main.c +++ b/fs/gfs2/locking/nolock/main.c @@ -14,8 +14,7 @@ #include #include #include - -#include "../../lm_interface.h" +#include struct nolock_lockspace { unsigned int nl_lvb_size; diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index ab341cd0a76aca..08b80b263ade90 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -14,9 +14,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "bmap.h" #include "glock.h" diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index f8f6d4b56a0195..e44d245d51d4bd 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -13,9 +13,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "glock.h" #include "log.h" diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index d2867988cc346b..7903be735fe9ad 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c @@ -15,10 +15,10 @@ #include #include #include +#include #include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "ops_fstype.h" #include "sys.h" diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 6af3521339fc24..a5630ec6c045fb 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -18,9 +18,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "glock.h" #include "glops.h" diff --git a/fs/gfs2/mount.c b/fs/gfs2/mount.c index 257c4a179dc6dc..ef3092e29607c5 100644 --- a/fs/gfs2/mount.c +++ b/fs/gfs2/mount.c @@ -13,9 +13,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "mount.h" #include "sys.h" diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 7cd53d118c89b5..91ec8080eeb264 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -17,9 +17,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "bmap.h" #include "glock.h" diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c index fa6ceffc7d82e6..00041b1b802522 100644 --- a/fs/gfs2/ops_dentry.c +++ b/fs/gfs2/ops_dentry.c @@ -15,9 +15,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "dir.h" #include "glock.h" diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index 470e8829e7f4b7..86127d93bd35f6 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c @@ -14,9 +14,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "dir.h" #include "glock.h" diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index b551074a3c9806..80f3ff0bba7bac 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c @@ -22,10 +22,10 @@ #include #include #include +#include #include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "bmap.h" #include "dir.h" diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index e8b7a1ae163b6f..e32a6b242e0cd0 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -17,9 +17,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "daemon.h" #include "glock.h" diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 2f38313b4bd539..bb2ef6a865335d 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -19,10 +19,10 @@ #include #include #include +#include #include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "acl.h" #include "bmap.h" diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 975e93b7992e29..f9538849c4181a 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -19,9 +19,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "glock.h" #include "inode.h" diff --git a/fs/gfs2/ops_vm.c b/fs/gfs2/ops_vm.c index 3b3463144126fd..5453d2947ab3a4 100644 --- a/fs/gfs2/ops_vm.c +++ b/fs/gfs2/ops_vm.c @@ -15,9 +15,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "bmap.h" #include "glock.h" diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index bc9ad058d20e60..c5eb6c646177d6 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -44,9 +44,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "bmap.h" #include "glock.h" diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index 130e9fbf96924d..518f9128137e6b 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -14,9 +14,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "bmap.h" #include "glock.h" diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 7a5ab817ad9c78..113b4ace6893e5 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -14,9 +14,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "glock.h" #include "glops.h" diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index f1d07d987c7bfd..fe207a3e206e9f 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -15,9 +15,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "bmap.h" #include "dir.h" diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index c9b23084918f4b..0e0ec988f731c5 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c @@ -15,10 +15,10 @@ #include #include #include +#include #include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "lm.h" #include "sys.h" diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index acf840160d5f75..f8dabf8446bb41 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -14,9 +14,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "glock.h" #include "log.h" diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c index d72eb8addc7a03..196c604faadcfe 100644 --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c @@ -14,10 +14,10 @@ #include #include #include +#include #include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "glock.h" #include "lm.h" diff --git a/include/linux/Kbuild b/include/linux/Kbuild index 2121cde187d879..d8e720f9c21aa4 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild @@ -45,9 +45,9 @@ unifdef-y += acct.h adb.h adfs_fs.h agpgart.h apm_bios.h atalk.h \ inet_diag.h in.h inotify.h input.h ipc.h ipmi.h ipv6.h \ ipv6_route.h isdn.h isdnif.h isdn_ppp.h isicom.h jbd.h \ joystick.h kdev_t.h kd.h kernelcapi.h kernel.h keyboard.h \ - llc.h loop.h lp.h mempolicy.h mii.h mman.h mroute.h msdos_fs.h \ - msg.h nbd.h ncp_fs.h ncp.h ncp_mount.h netdevice.h \ - netfilter_bridge.h netfilter_decnet.h netfilter.h \ + llc.h lm_interface.h loop.h lp.h mempolicy.h mii.h mman.h \ + mroute.h msdos_fs.h msg.h nbd.h ncp_fs.h ncp.h ncp_mount.h \ + netdevice.h netfilter_bridge.h netfilter_decnet.h netfilter.h \ netfilter_ipv4.h netfilter_ipv6.h netfilter_logging.h net.h \ netlink.h nfs3.h nfs4.h nfsacl.h nfs_fs.h nfs.h nfs_idmap.h \ n_r3964.h nubus.h nvram.h parport.h patchkey.h pci.h pktcdvd.h \ diff --git a/include/linux/lm_interface.h b/include/linux/lm_interface.h new file mode 100644 index 00000000000000..1418fdc9ac0261 --- /dev/null +++ b/include/linux/lm_interface.h @@ -0,0 +1,273 @@ +/* + * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. + * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License version 2. + */ + +#ifndef __LM_INTERFACE_DOT_H__ +#define __LM_INTERFACE_DOT_H__ + + +typedef void (*lm_callback_t) (void *ptr, unsigned int type, void *data); + +/* + * lm_mount() flags + * + * LM_MFLAG_SPECTATOR + * GFS is asking to join the filesystem's lockspace, but it doesn't want to + * modify the filesystem. The lock module shouldn't assign a journal to the FS + * mount. It shouldn't send recovery callbacks to the FS mount. If the node + * dies or withdraws, all locks can be wiped immediately. + */ + +#define LM_MFLAG_SPECTATOR 0x00000001 + +/* + * lm_lockstruct flags + * + * LM_LSFLAG_LOCAL + * The lock_nolock module returns LM_LSFLAG_LOCAL to GFS, indicating that GFS + * can make single-node optimizations. + */ + +#define LM_LSFLAG_LOCAL 0x00000001 + +/* + * lm_lockname types + */ + +#define LM_TYPE_RESERVED 0x00 +#define LM_TYPE_NONDISK 0x01 +#define LM_TYPE_INODE 0x02 +#define LM_TYPE_RGRP 0x03 +#define LM_TYPE_META 0x04 +#define LM_TYPE_IOPEN 0x05 +#define LM_TYPE_FLOCK 0x06 +#define LM_TYPE_PLOCK 0x07 +#define LM_TYPE_QUOTA 0x08 +#define LM_TYPE_JOURNAL 0x09 + +/* + * lm_lock() states + * + * SHARED is compatible with SHARED, not with DEFERRED or EX. + * DEFERRED is compatible with DEFERRED, not with SHARED or EX. + */ + +#define LM_ST_UNLOCKED 0 +#define LM_ST_EXCLUSIVE 1 +#define LM_ST_DEFERRED 2 +#define LM_ST_SHARED 3 + +/* + * lm_lock() flags + * + * LM_FLAG_TRY + * Don't wait to acquire the lock if it can't be granted immediately. + * + * LM_FLAG_TRY_1CB + * Send one blocking callback if TRY is set and the lock is not granted. + * + * LM_FLAG_NOEXP + * GFS sets this flag on lock requests it makes while doing journal recovery. + * These special requests should not be blocked due to the recovery like + * ordinary locks would be. + * + * LM_FLAG_ANY + * A SHARED request may also be granted in DEFERRED, or a DEFERRED request may + * also be granted in SHARED. The preferred state is whichever is compatible + * with other granted locks, or the specified state if no other locks exist. + * + * LM_FLAG_PRIORITY + * Override fairness considerations. Suppose a lock is held in a shared state + * and there is a pending request for the deferred state. A shared lock + * request with the priority flag would be allowed to bypass the deferred + * request and directly join the other shared lock. A shared lock request + * without the priority flag might be forced to wait until the deferred + * requested had acquired and released the lock. + */ + +#define LM_FLAG_TRY 0x00000001 +#define LM_FLAG_TRY_1CB 0x00000002 +#define LM_FLAG_NOEXP 0x00000004 +#define LM_FLAG_ANY 0x00000008 +#define LM_FLAG_PRIORITY 0x00000010 + +/* + * lm_lock() and lm_async_cb return flags + * + * LM_OUT_ST_MASK + * Masks the lower two bits of lock state in the returned value. + * + * LM_OUT_CACHEABLE + * The lock hasn't been released so GFS can continue to cache data for it. + * + * LM_OUT_CANCELED + * The lock request was canceled. + * + * LM_OUT_ASYNC + * The result of the request will be returned in an LM_CB_ASYNC callback. + */ + +#define LM_OUT_ST_MASK 0x00000003 +#define LM_OUT_CACHEABLE 0x00000004 +#define LM_OUT_CANCELED 0x00000008 +#define LM_OUT_ASYNC 0x00000080 +#define LM_OUT_ERROR 0x00000100 + +/* + * lm_callback_t types + * + * LM_CB_NEED_E LM_CB_NEED_D LM_CB_NEED_S + * Blocking callback, a remote node is requesting the given lock in + * EXCLUSIVE, DEFERRED, or SHARED. + * + * LM_CB_NEED_RECOVERY + * The given journal needs to be recovered. + * + * LM_CB_DROPLOCKS + * Reduce the number of cached locks. + * + * LM_CB_ASYNC + * The given lock has been granted. + */ + +#define LM_CB_NEED_E 257 +#define LM_CB_NEED_D 258 +#define LM_CB_NEED_S 259 +#define LM_CB_NEED_RECOVERY 260 +#define LM_CB_DROPLOCKS 261 +#define LM_CB_ASYNC 262 + +/* + * lm_recovery_done() messages + */ + +#define LM_RD_GAVEUP 308 +#define LM_RD_SUCCESS 309 + + +struct lm_lockname { + u64 ln_number; + unsigned int ln_type; +}; + +#define lm_name_equal(name1, name2) \ + (((name1)->ln_number == (name2)->ln_number) && \ + ((name1)->ln_type == (name2)->ln_type)) \ + +struct lm_async_cb { + struct lm_lockname lc_name; + int lc_ret; +}; + +struct lm_lockstruct; + +struct lm_lockops { + const char *lm_proto_name; + + /* + * Mount/Unmount + */ + + int (*lm_mount) (char *table_name, char *host_data, + lm_callback_t cb, void *cb_data, + unsigned int min_lvb_size, int flags, + struct lm_lockstruct *lockstruct, + struct kobject *fskobj); + + void (*lm_others_may_mount) (void *lockspace); + + void (*lm_unmount) (void *lockspace); + + void (*lm_withdraw) (void *lockspace); + + /* + * Lock oriented operations + */ + + int (*lm_get_lock) (void *lockspace, struct lm_lockname *name, void **lockp); + + void (*lm_put_lock) (void *lock); + + unsigned int (*lm_lock) (void *lock, unsigned int cur_state, + unsigned int req_state, unsigned int flags); + + unsigned int (*lm_unlock) (void *lock, unsigned int cur_state); + + void (*lm_cancel) (void *lock); + + int (*lm_hold_lvb) (void *lock, char **lvbp); + void (*lm_unhold_lvb) (void *lock, char *lvb); + + /* + * Posix Lock oriented operations + */ + + int (*lm_plock_get) (void *lockspace, struct lm_lockname *name, + struct file *file, struct file_lock *fl); + + int (*lm_plock) (void *lockspace, struct lm_lockname *name, + struct file *file, int cmd, struct file_lock *fl); + + int (*lm_punlock) (void *lockspace, struct lm_lockname *name, + struct file *file, struct file_lock *fl); + + /* + * Client oriented operations + */ + + void (*lm_recovery_done) (void *lockspace, unsigned int jid, + unsigned int message); + + struct module *lm_owner; +}; + +/* + * lm_mount() return values + * + * ls_jid - the journal ID this node should use + * ls_first - this node is the first to mount the file system + * ls_lvb_size - size in bytes of lock value blocks + * ls_lockspace - lock module's context for this file system + * ls_ops - lock module's functions + * ls_flags - lock module features + */ + +struct lm_lockstruct { + unsigned int ls_jid; + unsigned int ls_first; + unsigned int ls_lvb_size; + void *ls_lockspace; + const struct lm_lockops *ls_ops; + int ls_flags; +}; + +/* + * Lock module bottom interface. A lock module makes itself available to GFS + * with these functions. + */ + +int gfs2_register_lockproto(const struct lm_lockops *proto); +void gfs2_unregister_lockproto(const struct lm_lockops *proto); + +/* + * Lock module top interface. GFS calls these functions when mounting or + * unmounting a file system. + */ + +int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data, + lm_callback_t cb, void *cb_data, + unsigned int min_lvb_size, int flags, + struct lm_lockstruct *lockstruct, + struct kobject *fskobj); + +void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct); + +void gfs2_withdraw_lockproto(struct lm_lockstruct *lockstruct); + +#endif /* __LM_INTERFACE_DOT_H__ */ + -- cgit 1.2.3-korg From 907b9bceb41fa46beae93f79cc4a2247df502c0f Mon Sep 17 00:00:00 2001 From: Steven Whitehouse Date: Mon, 25 Sep 2006 09:26:04 -0400 Subject: [GFS2/DLM] Fix trailing whitespace As per Andrew Morton's request, removed trailing whitespace. Cc: Andrew Morton Signed-off-by: Steven Whitehouse --- fs/dlm/lock.c | 2 +- fs/gfs2/acl.c | 2 +- fs/gfs2/bmap.c | 4 ++-- fs/gfs2/daemon.c | 2 +- fs/gfs2/dir.c | 13 ++++++------- fs/gfs2/eaops.c | 2 +- fs/gfs2/eattr.c | 2 +- fs/gfs2/glock.c | 12 ++++++------ fs/gfs2/inode.c | 5 ++--- fs/gfs2/inode.h | 2 +- fs/gfs2/lm.c | 2 +- fs/gfs2/locking/dlm/thread.c | 4 ++-- fs/gfs2/lops.c | 2 +- fs/gfs2/main.c | 2 +- fs/gfs2/ops_address.c | 4 ++-- fs/gfs2/ops_file.c | 6 +++--- fs/gfs2/ops_fstype.c | 18 +++++++++--------- fs/gfs2/ops_inode.c | 2 +- fs/gfs2/ops_super.c | 2 +- fs/gfs2/quota.c | 6 +++--- fs/gfs2/recovery.c | 4 ++-- fs/gfs2/rgrp.c | 2 +- fs/gfs2/super.c | 5 ++--- 23 files changed, 51 insertions(+), 54 deletions(-) (limited to 'fs/gfs2/glock.c') diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c index af2f2f01bd5fd4..3f2befa4797b9a 100644 --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c @@ -1757,7 +1757,7 @@ static int do_unlock(struct dlm_rsb *r, struct dlm_lkb *lkb) skip the queue_cast(ECANCEL). It indicates that the request/convert completed (and queued a normal ast) just before the cancel; we don't want to clobber the sb_result for the normal ast with ECANCEL. */ - + static int do_cancel(struct dlm_rsb *r, struct dlm_lkb *lkb) { revert_lock(r, lkb); diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index 3123fc07123378..5f959b8ce4065d 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c @@ -181,7 +181,7 @@ int gfs2_check_acl(struct inode *inode, int mask) error = gfs2_check_acl_locked(inode, mask); gfs2_glock_dq_uninit(&i_gh); } - + return error; } diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 3fb9a26b6f5871..92eef825167d5b 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -130,7 +130,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) error = gfs2_meta_inode_buffer(ip, &dibh); if (error) goto out; - + if (ip->i_di.di_size) { /* Get a free block, fill it with the stuffed data, and write it out to disk */ @@ -246,7 +246,7 @@ static int build_height(struct inode *inode, unsigned height) blocks[n] = gfs2_meta_new(ip->i_gl, bn); gfs2_trans_add_bh(ip->i_gl, blocks[n], 1); } - + n = 0; bn = blocks[0]->b_blocknr; if (new_height > 1) { diff --git a/fs/gfs2/daemon.c b/fs/gfs2/daemon.c index a9908cd78cd948..cab1f68d468518 100644 --- a/fs/gfs2/daemon.c +++ b/fs/gfs2/daemon.c @@ -30,7 +30,7 @@ /* This uses schedule_timeout() instead of msleep() because it's good for the daemons to wake up more often than the timeout when unmounting so the user's unmount doesn't sit there forever. - + The kthread functions used to start these daemons block and flush signals. */ /** diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index 40e94ac0b93d36..459498cac93bdb 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -81,7 +81,7 @@ #define gfs2_disk_hash2offset(h) (((u64)(h)) >> 1) #define gfs2_dir_offset2hash(p) ((u32)(((u64)(p)) << 1)) -typedef int (*leaf_call_t) (struct gfs2_inode *dip, u32 index, u32 len, +typedef int (*leaf_call_t) (struct gfs2_inode *dip, u32 index, u32 len, u64 leaf_no, void *data); typedef int (*gfs2_dscan_t)(const struct gfs2_dirent *dent, const struct qstr *name, void *opaque); @@ -119,7 +119,6 @@ static int gfs2_dir_get_existing_buffer(struct gfs2_inode *ip, u64 block, static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf, unsigned int offset, unsigned int size) - { struct buffer_head *dibh; int error; @@ -685,7 +684,7 @@ static struct gfs2_dirent *gfs2_dirent_alloc(struct inode *inode, const struct qstr *name) { struct gfs2_dirent *dent; - dent = gfs2_dirent_scan(inode, bh->b_data, bh->b_size, + dent = gfs2_dirent_scan(inode, bh->b_data, bh->b_size, gfs2_dirent_find_space, name, NULL); if (!dent || IS_ERR(dent)) return dent; @@ -764,7 +763,7 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode, gfs2_consist_inode(ip); return ERR_PTR(-EIO); } - + index = name->hash >> (32 - ip->i_di.di_depth); error = get_first_leaf(ip, index, &bh); if (error) @@ -779,14 +778,14 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode, brelse(bh); if (!ln) break; - + error = get_leaf(ip, ln, &bh); } while(!error); return error ? ERR_PTR(error) : NULL; } - + error = gfs2_meta_inode_buffer(ip, &bh); if (error) return ERR_PTR(error); @@ -810,7 +809,7 @@ static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh, struct qstr name = { .name = "", .len = 0, .hash = 0 }; if (!bh) return NULL; - + gfs2_trans_add_bh(ip->i_gl, bh, 1); gfs2_metatype_set(bh, GFS2_METATYPE_LF, GFS2_FORMAT_LF); leaf = (struct gfs2_leaf *)bh->b_data; diff --git a/fs/gfs2/eaops.c b/fs/gfs2/eaops.c index 1a7877fe73934c..92c54e9b0dc3b8 100644 --- a/fs/gfs2/eaops.c +++ b/fs/gfs2/eaops.c @@ -146,7 +146,7 @@ static int system_eo_set(struct gfs2_inode *ip, struct gfs2_ea_request *er) if (error == -ENODATA) error = 0; } - return error; + return error; } return -EPERM; diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c index bd5ca602f9f094..a65a4ccfd4dd17 100644 --- a/fs/gfs2/eattr.c +++ b/fs/gfs2/eattr.c @@ -1133,7 +1133,7 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el) gfs2_trans_add_bh(ip->i_gl, dibh, 1); gfs2_dinode_out(&ip->i_di, dibh->b_data); brelse(dibh); - } + } gfs2_trans_end(GFS2_SB(&ip->i_inode)); diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index f98694e7d6685f..78fe0fae23ff53 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -371,7 +371,7 @@ fail_aspace: if (gl->gl_aspace) gfs2_aspace_put(gl->gl_aspace); fail: - kmem_cache_free(gfs2_glock_cachep, gl); + kmem_cache_free(gfs2_glock_cachep, gl); return error; } @@ -614,7 +614,7 @@ static int rq_greedy(struct gfs2_holder *gh) gfs2_holder_uninit(gh); kfree(container_of(gh, struct greedy, gr_gh)); - spin_lock(&gl->gl_spin); + spin_lock(&gl->gl_spin); return 0; } @@ -1184,11 +1184,11 @@ static void add_to_queue(struct gfs2_holder *gh) if (existing) { print_symbol(KERN_WARNING "original: %s\n", existing->gh_ip); printk(KERN_INFO "pid : %d\n", existing->gh_owner->pid); - printk(KERN_INFO "lock type : %d lock state : %d\n", + printk(KERN_INFO "lock type : %d lock state : %d\n", existing->gh_gl->gl_name.ln_type, existing->gh_gl->gl_state); print_symbol(KERN_WARNING "new: %s\n", gh->gh_ip); printk(KERN_INFO "pid : %d\n", gh->gh_owner->pid); - printk(KERN_INFO "lock type : %d lock state : %d\n", + printk(KERN_INFO "lock type : %d lock state : %d\n", gl->gl_name.ln_type, gl->gl_state); BUG(); } @@ -1203,7 +1203,7 @@ static void add_to_queue(struct gfs2_holder *gh) if (gh->gh_flags & LM_FLAG_PRIORITY) list_add(&gh->gh_list, &gl->gl_waiters3); else - list_add_tail(&gh->gh_list, &gl->gl_waiters3); + list_add_tail(&gh->gh_list, &gl->gl_waiters3); } /** @@ -2003,7 +2003,7 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait) for (;;) { cont = 0; for (x = 0; x < GFS2_GL_HASH_SIZE; x++) { - if (examine_bucket(clear_glock, sdp, x)) + if (examine_bucket(clear_glock, sdp, x)) cont = 1; } diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index b9e4bcb3bf1e18..ac9535be304f07 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -386,7 +386,6 @@ struct inode *gfs2_lookup_simple(struct inode *dip, const char *name) struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, int is_root, struct nameidata *nd) - { struct super_block *sb = dir->i_sb; struct gfs2_inode *dip = GFS2_I(dir); @@ -491,7 +490,7 @@ static int pick_formal_ino_2(struct gfs2_sbd *sdp, u64 *formal_ino) error = gfs2_meta_inode_buffer(ip, &bh); if (error) goto out_end_trans; - + gfs2_inum_range_in(&ir, bh->b_data + sizeof(struct gfs2_dinode)); if (!ir.ir_length) { @@ -769,7 +768,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name, error = gfs2_trans_begin(sdp, sdp->sd_max_dirres + al->al_rgd->rd_ri.ri_length + - 2 * RES_DINODE + + 2 * RES_DINODE + RES_STATFS + RES_QUOTA, 0); if (error) goto fail_ipreserv; diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h index 32015d89f24999..f5d8617605795b 100644 --- a/fs/gfs2/inode.h +++ b/fs/gfs2/inode.h @@ -34,7 +34,7 @@ int gfs2_inode_refresh(struct gfs2_inode *ip); int gfs2_dinode_dealloc(struct gfs2_inode *inode); int gfs2_change_nlink(struct gfs2_inode *ip, int diff); -struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, +struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, int is_root, struct nameidata *nd); struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, unsigned int mode); diff --git a/fs/gfs2/lm.c b/fs/gfs2/lm.c index 2109fc4791d4b9..effe4a337c1dbc 100644 --- a/fs/gfs2/lm.c +++ b/fs/gfs2/lm.c @@ -106,7 +106,7 @@ int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...) fs_err(sdp, "about to withdraw from the cluster\n"); BUG_ON(sdp->sd_args.ar_debug); - + fs_err(sdp, "waiting for outstanding I/O\n"); diff --git a/fs/gfs2/locking/dlm/thread.c b/fs/gfs2/locking/dlm/thread.c index 554bf882a4c2bf..9cf1f168eaf8b2 100644 --- a/fs/gfs2/locking/dlm/thread.c +++ b/fs/gfs2/locking/dlm/thread.c @@ -54,7 +54,7 @@ static void process_complete(struct gdlm_lock *lp) if (lp->lksb.sb_status == -DLM_ECANCEL) { log_info("complete dlm cancel %x,%llx flags %lx", - lp->lockname.ln_type, + lp->lockname.ln_type, (unsigned long long)lp->lockname.ln_number, lp->flags); @@ -102,7 +102,7 @@ static void process_complete(struct gdlm_lock *lp) if (test_and_clear_bit(LFL_CANCEL, &lp->flags)) { log_info("complete internal cancel %x,%llx", - lp->lockname.ln_type, + lp->lockname.ln_type, (unsigned long long)lp->lockname.ln_number); lp->req = lp->cur; acb.lc_ret |= LM_OUT_CANCELED; diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 2a98cbe3290f0f..881e337b6a70ab 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -420,7 +420,7 @@ static void rg_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) gfs2_log_lock(sdp); sdp->sd_log_num_rg++; list_add(&le->le_list, &sdp->sd_log_le_rg); - gfs2_log_unlock(sdp); + gfs2_log_unlock(sdp); } static void rg_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index 7903be735fe9ad..21508a13bb78d7 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c @@ -77,7 +77,7 @@ static int __init init_gfs2_fs(void) error = -ENOMEM; gfs2_glock_cachep = kmem_cache_create("gfs2_glock", sizeof(struct gfs2_glock), - 0, 0, + 0, 0, gfs2_init_glock_once, NULL); if (!gfs2_glock_cachep) goto fail; diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 8b18e974fa4dbb..811f4ada2a019e 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c @@ -296,7 +296,7 @@ static int gfs2_readpages(struct file *file, struct address_space *mapping, LM_FLAG_TRY_1CB|GL_ATIME|GL_AOP, &gh); do_unlock = 1; ret = gfs2_glock_nq_m_atime(1, &gh); - if (ret == GLR_TRYFAILED) + if (ret == GLR_TRYFAILED) goto out_noerror; if (unlikely(ret)) goto out_unlock; @@ -681,7 +681,7 @@ static unsigned limit = 0; gl = bd->bd_gl; - fs_warn(sdp, "gl = (%u, %llu)\n", + fs_warn(sdp, "gl = (%u, %llu)\n", gl->gl_name.ln_type, (unsigned long long)gl->gl_name.ln_number); fs_warn(sdp, "bd_list_tr = %s, bd_le.le_list = %s\n", diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index 372dbcb3f7f304..a9ac1358ce21ca 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c @@ -236,7 +236,7 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr) error = gfs2_glock_nq_m_atime(1, &gh); if (error) return error; - + iflags = iflags_cvt(gfs2_to_iflags, ip->i_di.di_flags); if (put_user(iflags, ptr)) error = -EFAULT; @@ -299,7 +299,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask) goto out; if (IS_APPEND(inode) && (new_flags & GFS2_DIF_APPENDONLY)) goto out; - if (((new_flags ^ flags) & GFS2_DIF_IMMUTABLE) && + if (((new_flags ^ flags) & GFS2_DIF_IMMUTABLE) && !capable(CAP_LINUX_IMMUTABLE)) goto out; if (!IS_IMMUTABLE(inode)) { @@ -541,7 +541,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) goto out; gfs2_glock_hold(gl); flock_lock_file_wait(file, - &(struct file_lock){.fl_type = F_UNLCK}); + &(struct file_lock){.fl_type = F_UNLCK}); gfs2_glock_dq_uninit(fl_gh); } else { error = gfs2_glock_get(GFS2_SB(&ip->i_inode), diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index e32a6b242e0cd0..a9aa2edd756fcc 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -146,7 +146,7 @@ static int init_names(struct gfs2_sbd *sdp, int silent) brelse(bh); return -ENOMEM; } - gfs2_sb_in(sb, bh->b_data); + gfs2_sb_in(sb, bh->b_data); brelse(bh); error = gfs2_check_sb(sdp, sb, silent); @@ -272,7 +272,7 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo) } return 0; } - + error = gfs2_glock_nq_num(sdp, GFS2_SB_LOCK, &gfs2_meta_glops, LM_ST_SHARED, 0, &sb_gh); if (error) { @@ -358,7 +358,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) error = -EINVAL; if (!gfs2_jindex_size(sdp)) { fs_err(sdp, "no journals!\n"); - goto fail_jindex; + goto fail_jindex; } if (sdp->sd_args.ar_spectator) { @@ -789,7 +789,7 @@ out: return error; } -static int fill_super_meta(struct super_block *sb, struct super_block *new, +static int fill_super_meta(struct super_block *sb, struct super_block *new, void *data, int silent) { struct gfs2_sbd *sdp = sb->s_fs_info; @@ -821,7 +821,7 @@ static int set_bdev_super(struct super_block *s, void *data) s->s_dev = s->s_bdev->bd_dev; return 0; } - + static int test_bdev_super(struct super_block *s, void *data) { return s->s_bdev == data; @@ -835,10 +835,10 @@ static struct super_block* get_gfs2_sb(const char *dev_name) struct super_block *sb = NULL, *s; struct list_head *l; int error; - + error = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); if (error) { - printk(KERN_WARNING "GFS2: path_lookup on %s returned error\n", + printk(KERN_WARNING "GFS2: path_lookup on %s returned error\n", dev_name); goto out; } @@ -900,9 +900,9 @@ static int gfs2_get_sb_meta(struct file_system_type *fs_type, int flags, deactivate_super(new); goto error; } - + new->s_flags |= MS_ACTIVE; - + /* Grab a reference to the gfs2 mount point */ atomic_inc(&sdp->sd_gfs2mnt->mnt_count); return simple_set_mnt(mnt, new); diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index bb2ef6a865335d..57af0192b24169 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c @@ -522,7 +522,7 @@ static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, case S_IFSOCK: break; default: - return -EOPNOTSUPP; + return -EOPNOTSUPP; }; gfs2_holder_init(dip->i_gl, 0, 0, ghs); diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index f9538849c4181a..8cfda64521393f 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c @@ -367,7 +367,7 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) return 0; } -/* +/* * We have to (at the moment) hold the inodes main lock to cover * the gap between unlocking the shared lock on the iopen lock and * taking the exclusive lock. I'd rather do a shared -> exclusive diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index da46e14388f4bd..c0a3c9a2a593de 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -556,7 +556,7 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change) qd_hold(qd); slot_hold(qd); } - + mutex_unlock(&sdp->sd_quota_mutex); } @@ -777,7 +777,7 @@ restart: gfs2_glock_dq_uninit(&i_gh); - + gfs2_quota_in(&q, buf); qlvb = (struct gfs2_quota_lvb *)qd->qd_gl->gl_lvb; qlvb->qb_magic = cpu_to_be32(GFS2_MAGIC); @@ -1062,7 +1062,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp) if (!ip->i_di.di_size || ip->i_di.di_size > (64 << 20) || ip->i_di.di_size & (sdp->sd_sb.sb_bsize - 1)) { gfs2_consist_inode(ip); - return -EIO; + return -EIO; } sdp->sd_quota_slots = blocks * sdp->sd_qc_per_block; sdp->sd_quota_chunks = DIV_ROUND_UP(sdp->sd_quota_slots, 8 * PAGE_SIZE); diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index 4d4ea7e66edc07..0a8a4b87dcc643 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -444,11 +444,11 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd) switch (error) { case 0: break; - + case GLR_TRYFAILED: fs_info(sdp, "jid=%u: Busy\n", jd->jd_jid); error = 0; - + default: goto fail; }; diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 5f8e225c54977e..b261385c006556 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -896,7 +896,7 @@ static int get_local_rgrp(struct gfs2_inode *ip) rgd = recent_rgrp_first(sdp, ip->i_last_rg_alloc); while (rgd) { - error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, + error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, LM_FLAG_TRY, &al->al_rgd_gh); switch (error) { case 0: diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index fe207a3e206e9f..f6ce5e4eaf7e99 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -650,8 +650,7 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free, l_sc->sc_total += total; l_sc->sc_free += free; l_sc->sc_dinodes += dinodes; - gfs2_statfs_change_out(l_sc, l_bh->b_data + - sizeof(struct gfs2_dinode)); + gfs2_statfs_change_out(l_sc, l_bh->b_data + sizeof(struct gfs2_dinode)); spin_unlock(&sdp->sd_statfs_spin); brelse(l_bh); @@ -678,7 +677,7 @@ int gfs2_statfs_sync(struct gfs2_sbd *sdp) spin_lock(&sdp->sd_statfs_spin); gfs2_statfs_change_in(m_sc, m_bh->b_data + - sizeof(struct gfs2_dinode)); + sizeof(struct gfs2_dinode)); if (!l_sc->sc_total && !l_sc->sc_free && !l_sc->sc_dinodes) { spin_unlock(&sdp->sd_statfs_spin); goto out_bh; -- cgit 1.2.3-korg