]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/gfs2/ops_address.c
[GFS2] Addendum patch 2 for gfs2_grow
[linux-2.6-omap-h63xx.git] / fs / gfs2 / ops_address.c
index 30c15622174fdbc59f3b94ab8cec331001b2a943..4913ef57b0955a9dfb73dcb1571dc9e98f53901d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
- * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
+ * Copyright (C) 2004-2007 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
@@ -32,6 +32,7 @@
 #include "trans.h"
 #include "rgrp.h"
 #include "ops_file.h"
+#include "super.h"
 #include "util.h"
 #include "glops.h"
 
@@ -449,6 +450,31 @@ out_uninit:
        return error;
 }
 
+/**
+ * adjust_fs_space - Adjusts the free space available due to gfs2_grow
+ * @inode: the rindex inode
+ */
+static void adjust_fs_space(struct inode *inode)
+{
+       struct gfs2_sbd *sdp = inode->i_sb->s_fs_info;
+       struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
+       struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
+       u64 fs_total, new_free;
+
+       /* Total up the file system space, according to the latest rindex. */
+       fs_total = gfs2_ri_total(sdp);
+
+       spin_lock(&sdp->sd_statfs_spin);
+       if (fs_total > (m_sc->sc_total + l_sc->sc_total))
+               new_free = fs_total - (m_sc->sc_total + l_sc->sc_total);
+       else
+               new_free = 0;
+       spin_unlock(&sdp->sd_statfs_spin);
+       fs_warn(sdp, "File system extended by %llu blocks.\n",
+               (unsigned long long)new_free);
+       gfs2_statfs_change(sdp, new_free, new_free, 0);
+}
+
 /**
  * gfs2_commit_write - Commit write to a file
  * @file: The file to write to
@@ -511,6 +537,9 @@ static int gfs2_commit_write(struct file *file, struct page *page,
                di->di_size = cpu_to_be64(inode->i_size);
        }
 
+       if (inode == sdp->sd_rindex)
+               adjust_fs_space(inode);
+
        brelse(dibh);
        gfs2_trans_end(sdp);
        if (al->al_requested) {