aboutsummaryrefslogtreecommitdiff
path: root/fs/gfs2/log.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-03-28 14:14:04 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2006-03-28 14:14:04 -0500
commit71b86f562b5eb6f94ea00bba060caa64d0137969 (patch)
tree63d982e09a9cb934fe656afe115031c0a9dc5e4a /fs/gfs2/log.c
parent94aabbd99370f738da4f6cb4ea0b94cd9024002f (diff)
[GFS2] Further updates to dir and logging code
This reduces the size of the directory code by about 3k and gets readdir() to use the functions which were introduced in the previous directory code update. Two memory allocations are merged into one. Eliminates zeroing of some buffers which were never used before they were initialised by other data. There is still scope for further improvement in the directory code. On the logging side, a hand created mutex has been replaced by a standard Linux mutex in the log allocation code. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/log.c')
-rw-r--r--fs/gfs2/log.c34
1 files changed, 6 insertions, 28 deletions
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index e6a84f7a9b7..16c14441a37 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -13,6 +13,7 @@
#include <linux/completion.h>
#include <linux/buffer_head.h>
#include <linux/gfs2_ondisk.h>
+#include <linux/crc32.h>
#include <asm/semaphore.h>
#include "gfs2.h"
@@ -24,18 +25,13 @@
#include "lops.h"
#include "meta_io.h"
#include "util.h"
+#include "dir.h"
#define PULL 1
-static void do_lock_wait(struct gfs2_sbd *sdp, wait_queue_head_t *wq,
- atomic_t *a)
-{
- wait_event(*wq, atomic_read(a) ? 0 : 1);
-}
-
static void lock_for_trans(struct gfs2_sbd *sdp)
{
- do_lock_wait(sdp, &sdp->sd_log_trans_wq, &sdp->sd_log_flush_count);
+ wait_event(sdp->sd_log_trans_wq, atomic_read(&sdp->sd_log_flush_count) ? 0 : 1);
atomic_inc(&sdp->sd_log_trans_count);
}
@@ -49,7 +45,7 @@ static void unlock_from_trans(struct gfs2_sbd *sdp)
static void gfs2_lock_for_flush(struct gfs2_sbd *sdp)
{
atomic_inc(&sdp->sd_log_flush_count);
- do_lock_wait(sdp, &sdp->sd_log_flush_wq, &sdp->sd_log_trans_count);
+ wait_event(sdp->sd_log_flush_wq, atomic_read(&sdp->sd_log_trans_count) ? 0 : 1);
}
static void gfs2_unlock_from_flush(struct gfs2_sbd *sdp)
@@ -191,37 +187,19 @@ static void ail2_empty(struct gfs2_sbd *sdp, unsigned int new_tail)
int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks)
{
- LIST_HEAD(list);
unsigned int try = 0;
if (gfs2_assert_warn(sdp, blks) ||
gfs2_assert_warn(sdp, blks <= sdp->sd_jdesc->jd_blocks))
return -EINVAL;
+ mutex_lock(&sdp->sd_log_reserve_mutex);
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) {
- DECLARE_WAITQUEUE(__wait_chan, current);
- set_current_state(TASK_UNINTERRUPTIBLE);
- add_wait_queue(&sdp->sd_log_blks_wait,
- &__wait_chan);
- gfs2_log_unlock(sdp);
- schedule();
- gfs2_log_lock(sdp);
- remove_wait_queue(&sdp->sd_log_blks_wait,
- &__wait_chan);
- 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) {
sdp->sd_log_blks_free -= blks;
- list_del(&list);
gfs2_log_unlock(sdp);
- wake_up(&sdp->sd_log_blks_wait);
+ mutex_unlock(&sdp->sd_log_reserve_mutex);
break;
}