GFS2: Move four functions from super.c
authorSteven Whitehouse <swhiteho@redhat.com>
Wed, 26 Nov 2008 13:30:49 +0000 (13:30 +0000)
committerSteven Whitehouse <swhiteho@redhat.com>
Mon, 5 Jan 2009 07:39:12 +0000 (07:39 +0000)
The functions which are being moved can all be marked
static in their new locations, since they only have
a single caller each. Their new locations are more
logical than before and some of the functions are
small enough that the compiler might well inline them.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
fs/gfs2/glock.c
fs/gfs2/ops_super.c
fs/gfs2/recovery.c
fs/gfs2/super.c
fs/gfs2/super.h

index 07ffc8123d744ec4c3c3ba3e982596c357a780ec..6e298b07011744348b94844f6ac9dd2aaf82f3fd 100644 (file)
@@ -1317,6 +1317,20 @@ static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name,
                gfs2_glock_put(gl);
 }
 
+static void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid)
+{
+       struct gfs2_jdesc *jd;
+
+       spin_lock(&sdp->sd_jindex_spin);
+       list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
+               if (jd->jd_jid != jid)
+                       continue;
+               jd->jd_dirty = 1;
+               break;
+       }
+       spin_unlock(&sdp->sd_jindex_spin);
+}
+
 /**
  * gfs2_glock_cb - Callback used by locking module
  * @sdp: Pointer to the superblock
index 29f8a5c0b45b0e86656c34a42e3bd599d1b48bb7..08837a728635d9ea06d6cff998a86b7531847b6c 100644 (file)
@@ -256,6 +256,137 @@ static void gfs2_unlockfs(struct super_block *sb)
        gfs2_unfreeze_fs(sb->s_fs_info);
 }
 
+/**
+ * statfs_fill - fill in the sg for a given RG
+ * @rgd: the RG
+ * @sc: the sc structure
+ *
+ * Returns: 0 on success, -ESTALE if the LVB is invalid
+ */
+
+static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
+                           struct gfs2_statfs_change_host *sc)
+{
+       gfs2_rgrp_verify(rgd);
+       sc->sc_total += rgd->rd_data;
+       sc->sc_free += rgd->rd_free;
+       sc->sc_dinodes += rgd->rd_dinodes;
+       return 0;
+}
+
+/**
+ * gfs2_statfs_slow - Stat a filesystem using asynchronous locking
+ * @sdp: the filesystem
+ * @sc: the sc info that will be returned
+ *
+ * Any error (other than a signal) will cause this routine to fall back
+ * to the synchronous version.
+ *
+ * FIXME: This really shouldn't busy wait like this.
+ *
+ * Returns: errno
+ */
+
+static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
+{
+       struct gfs2_holder ri_gh;
+       struct gfs2_rgrpd *rgd_next;
+       struct gfs2_holder *gha, *gh;
+       unsigned int slots = 64;
+       unsigned int x;
+       int done;
+       int error = 0, err;
+
+       memset(sc, 0, sizeof(struct gfs2_statfs_change_host));
+       gha = kcalloc(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
+       if (!gha)
+               return -ENOMEM;
+
+       error = gfs2_rindex_hold(sdp, &ri_gh);
+       if (error)
+               goto out;
+
+       rgd_next = gfs2_rgrpd_get_first(sdp);
+
+       for (;;) {
+               done = 1;
+
+               for (x = 0; x < slots; x++) {
+                       gh = gha + x;
+
+                       if (gh->gh_gl && gfs2_glock_poll(gh)) {
+                               err = gfs2_glock_wait(gh);
+                               if (err) {
+                                       gfs2_holder_uninit(gh);
+                                       error = err;
+                               } else {
+                                       if (!error)
+                                               error = statfs_slow_fill(
+                                                       gh->gh_gl->gl_object, sc);
+                                       gfs2_glock_dq_uninit(gh);
+                               }
+                       }
+
+                       if (gh->gh_gl)
+                               done = 0;
+                       else if (rgd_next && !error) {
+                               error = gfs2_glock_nq_init(rgd_next->rd_gl,
+                                                          LM_ST_SHARED,
+                                                          GL_ASYNC,
+                                                          gh);
+                               rgd_next = gfs2_rgrpd_get_next(rgd_next);
+                               done = 0;
+                       }
+
+                       if (signal_pending(current))
+                               error = -ERESTARTSYS;
+               }
+
+               if (done)
+                       break;
+
+               yield();
+       }
+
+       gfs2_glock_dq_uninit(&ri_gh);
+
+out:
+       kfree(gha);
+       return error;
+}
+
+/**
+ * gfs2_statfs_i - Do a statfs
+ * @sdp: the filesystem
+ * @sg: the sg structure
+ *
+ * Returns: errno
+ */
+
+static int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
+{
+       struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
+       struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
+
+       spin_lock(&sdp->sd_statfs_spin);
+
+       *sc = *m_sc;
+       sc->sc_total += l_sc->sc_total;
+       sc->sc_free += l_sc->sc_free;
+       sc->sc_dinodes += l_sc->sc_dinodes;
+
+       spin_unlock(&sdp->sd_statfs_spin);
+
+       if (sc->sc_free < 0)
+               sc->sc_free = 0;
+       if (sc->sc_free > sc->sc_total)
+               sc->sc_free = sc->sc_total;
+       if (sc->sc_dinodes < 0)
+               sc->sc_dinodes = 0;
+
+       return 0;
+}
+
 /**
  * gfs2_statfs - Gather and return stats about the filesystem
  * @sb: The superblock
index b56ba3db77714b7671a3abf830c26e0d00e29517..efd09c3d2b26975b5497b323497d2b3d802bd452 100644 (file)
@@ -585,6 +585,28 @@ fail:
        return error;
 }
 
+static struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp)
+{
+       struct gfs2_jdesc *jd;
+       int found = 0;
+
+       spin_lock(&sdp->sd_jindex_spin);
+
+       list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
+               if (jd->jd_dirty) {
+                       jd->jd_dirty = 0;
+                       found = 1;
+                       break;
+               }
+       }
+       spin_unlock(&sdp->sd_jindex_spin);
+
+       if (!found)
+               jd = NULL;
+
+       return jd;
+}
+
 /**
  * gfs2_check_journals - Recover any dirty journals
  * @sdp: the filesystem
index 3dd9f5788cb04510fd8ed9d87c2a37602cd3d02a..141b781f2fccd10dede6cc27e04ead232af65f28 100644 (file)
@@ -96,39 +96,6 @@ struct gfs2_jdesc *gfs2_jdesc_find(struct gfs2_sbd *sdp, unsigned int jid)
        return jd;
 }
 
-void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid)
-{
-       struct gfs2_jdesc *jd;
-
-       spin_lock(&sdp->sd_jindex_spin);
-       jd = jdesc_find_i(&sdp->sd_jindex_list, jid);
-       if (jd)
-               jd->jd_dirty = 1;
-       spin_unlock(&sdp->sd_jindex_spin);
-}
-
-struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp)
-{
-       struct gfs2_jdesc *jd;
-       int found = 0;
-
-       spin_lock(&sdp->sd_jindex_spin);
-
-       list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
-               if (jd->jd_dirty) {
-                       jd->jd_dirty = 0;
-                       found = 1;
-                       break;
-               }
-       }
-       spin_unlock(&sdp->sd_jindex_spin);
-
-       if (!found)
-               jd = NULL;
-
-       return jd;
-}
-
 int gfs2_jdesc_check(struct gfs2_jdesc *jd)
 {
        struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
@@ -353,137 +320,6 @@ out:
        return error;
 }
 
-/**
- * gfs2_statfs_i - Do a statfs
- * @sdp: the filesystem
- * @sg: the sg structure
- *
- * Returns: errno
- */
-
-int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
-{
-       struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
-       struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
-
-       spin_lock(&sdp->sd_statfs_spin);
-
-       *sc = *m_sc;
-       sc->sc_total += l_sc->sc_total;
-       sc->sc_free += l_sc->sc_free;
-       sc->sc_dinodes += l_sc->sc_dinodes;
-
-       spin_unlock(&sdp->sd_statfs_spin);
-
-       if (sc->sc_free < 0)
-               sc->sc_free = 0;
-       if (sc->sc_free > sc->sc_total)
-               sc->sc_free = sc->sc_total;
-       if (sc->sc_dinodes < 0)
-               sc->sc_dinodes = 0;
-
-       return 0;
-}
-
-/**
- * statfs_fill - fill in the sg for a given RG
- * @rgd: the RG
- * @sc: the sc structure
- *
- * Returns: 0 on success, -ESTALE if the LVB is invalid
- */
-
-static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
-                           struct gfs2_statfs_change_host *sc)
-{
-       gfs2_rgrp_verify(rgd);
-       sc->sc_total += rgd->rd_data;
-       sc->sc_free += rgd->rd_free;
-       sc->sc_dinodes += rgd->rd_dinodes;
-       return 0;
-}
-
-/**
- * gfs2_statfs_slow - Stat a filesystem using asynchronous locking
- * @sdp: the filesystem
- * @sc: the sc info that will be returned
- *
- * Any error (other than a signal) will cause this routine to fall back
- * to the synchronous version.
- *
- * FIXME: This really shouldn't busy wait like this.
- *
- * Returns: errno
- */
-
-int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
-{
-       struct gfs2_holder ri_gh;
-       struct gfs2_rgrpd *rgd_next;
-       struct gfs2_holder *gha, *gh;
-       unsigned int slots = 64;
-       unsigned int x;
-       int done;
-       int error = 0, err;
-
-       memset(sc, 0, sizeof(struct gfs2_statfs_change_host));
-       gha = kcalloc(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
-       if (!gha)
-               return -ENOMEM;
-
-       error = gfs2_rindex_hold(sdp, &ri_gh);
-       if (error)
-               goto out;
-
-       rgd_next = gfs2_rgrpd_get_first(sdp);
-
-       for (;;) {
-               done = 1;
-
-               for (x = 0; x < slots; x++) {
-                       gh = gha + x;
-
-                       if (gh->gh_gl && gfs2_glock_poll(gh)) {
-                               err = gfs2_glock_wait(gh);
-                               if (err) {
-                                       gfs2_holder_uninit(gh);
-                                       error = err;
-                               } else {
-                                       if (!error)
-                                               error = statfs_slow_fill(
-                                                       gh->gh_gl->gl_object, sc);
-                                       gfs2_glock_dq_uninit(gh);
-                               }
-                       }
-
-                       if (gh->gh_gl)
-                               done = 0;
-                       else if (rgd_next && !error) {
-                               error = gfs2_glock_nq_init(rgd_next->rd_gl,
-                                                          LM_ST_SHARED,
-                                                          GL_ASYNC,
-                                                          gh);
-                               rgd_next = gfs2_rgrpd_get_next(rgd_next);
-                               done = 0;
-                       }
-
-                       if (signal_pending(current))
-                               error = -ERESTARTSYS;
-               }
-
-               if (done)
-                       break;
-
-               yield();
-       }
-
-       gfs2_glock_dq_uninit(&ri_gh);
-
-out:
-       kfree(gha);
-       return error;
-}
-
 struct lfcc {
        struct list_head list;
        struct gfs2_holder gh;
index c6254596713a7a9e0c260f81a4891e440834050d..f6b8b00ad8811b6b12c096f7214d563d8afe7e0c 100644 (file)
@@ -28,8 +28,6 @@ static inline unsigned int gfs2_jindex_size(struct gfs2_sbd *sdp)
 void gfs2_jindex_free(struct gfs2_sbd *sdp);
 
 struct gfs2_jdesc *gfs2_jdesc_find(struct gfs2_sbd *sdp, unsigned int jid);
-void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid);
-struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp);
 int gfs2_jdesc_check(struct gfs2_jdesc *jd);
 
 int gfs2_lookup_in_master_dir(struct gfs2_sbd *sdp, char *filename,
@@ -41,8 +39,6 @@ int gfs2_statfs_init(struct gfs2_sbd *sdp);
 void gfs2_statfs_change(struct gfs2_sbd *sdp,
                        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_host *sc);
-int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc);
 
 int gfs2_freeze_fs(struct gfs2_sbd *sdp);
 void gfs2_unfreeze_fs(struct gfs2_sbd *sdp);