]> git.neil.brown.name Git - LaFS.git/commitdiff
Create a backing_dev_info for a lafs filesystem.
authorNeilBrown <neilb@suse.de>
Mon, 9 Aug 2010 04:06:58 +0000 (14:06 +1000)
committerNeilBrown <neilb@suse.de>
Fri, 13 Aug 2010 09:36:13 +0000 (19:36 +1000)
As a lafs filesystem can span multiple devices, we need our own
bdi to handle congestion notification and unplugging.

Signed-off-by: NeilBrown <neilb@suse.de>
file.c
state.h
super.c

diff --git a/file.c b/file.c
index d311dcc4c14f86dcc332099cdd4a08a3c32c1be5..3d763ce46025ffda31999ca7256b35833aa0b590 100644 (file)
--- a/file.c
+++ b/file.c
@@ -302,7 +302,7 @@ lafs_writepage(struct page *page, struct writeback_control *wbc)
        int blocks = PAGE_SIZE >> ino->i_blkbits;
        int i;
        int redirty = 0;
-       dprintk("WRITEPAGE %lu\n", page->index);
+       dprintk("WRITEPAGE %lu/%lu/%lu\n", ino_from_sb(ino->i_sb)->i_ino, ino->i_ino, page->index * blocks);
        for (i = 0 ; i < blocks; i++) {
                struct datablock *b = lafs_get_block(ino, i, page, GFP_KERNEL,
                                                     MKREF(writepage));
diff --git a/state.h b/state.h
index 6750c2bd1c90ea7857c9e8645fad4f09e6f287b5..806716b943894373ed399dd9ecef1deac8a4b7e9 100644 (file)
--- a/state.h
+++ b/state.h
@@ -221,6 +221,7 @@ struct fs {
        struct list_head flush_list; /* list of qents that need flushing */
        struct list_head qhash[QHASHSIZE];
 
+       struct backing_dev_info bdi;
        struct fs_dev {
                struct block_device *bdev;
                struct lafs_dev *devblk;
diff --git a/super.c b/super.c
index f11820bf011c492ebec8f3dc3155db0a061c173e..4eddc61549dbd413615800760f1a35058847a299 100644 (file)
--- a/super.c
+++ b/super.c
@@ -556,6 +556,12 @@ lafs_load(struct fs *fs, struct options *op, int newest)
 
        INIT_WORK(&fs->done_work, lafs_done_work);
 
+       /* FIXME add congention and unplug functions to this bdi */
+       err = bdi_init(&fs->bdi);
+       if (err)
+               goto abort;
+       
+
        fs->phase_locked = 0;
        for (i = 0; i < WC_NUM; i++) {
                int j;
@@ -587,12 +593,21 @@ lafs_load(struct fs *fs, struct options *op, int newest)
        }
        if (fs->prime_sb->s_root) {
                /* filesystem with this uuid already exists */
-               kfree(k);
                deactivate_locked_super(fs->prime_sb);
+               kfree(k);
                fs->prime_sb = NULL;
                err = -EBUSY;
                goto abort;
        }
+       err = bdi_register_dev(&fs->bdi, fs->prime_sb->s_dev);
+       if (err) {
+               deactivate_locked_super(fs->prime_sb);
+               kfree(k);
+               fs->prime_sb = NULL;
+               goto abort;
+       }
+       fs->prime_sb->s_bdi = &fs->bdi;
+
        fs->prime_sb->s_blocksize = 1 << op->blockbits;
        fs->prime_sb->s_blocksize_bits = op->blockbits;
        fs->prime_sb->s_op = &lafs_sops;
@@ -653,6 +668,7 @@ lafs_load(struct fs *fs, struct options *op, int newest)
        return 0;
 
 abort:
+       bdi_destroy(&fs->bdi);
        kfree(fs->scan.free_usages);
        lafs_segtrack_free(fs->segtrack);
        kfree(fs->devs);
@@ -707,6 +723,8 @@ static void lafs_kill_sb(struct super_block *sb)
 
        kill_anon_super(fs->prime_sb);
 
+       bdi_destroy(&fs->bdi);
+
        for (i = 0; i < fs->devices; i++) {
                struct fs_dev *dv = &fs->devs[i];
                kfree(dv->devblk);
@@ -1194,7 +1212,7 @@ static struct inode *lafs_alloc_inode(struct super_block *sb)
        if (!li)
                return NULL;
        inode_init_once(&li->vfs_inode);
-
+       li->vfs_inode.i_data.backing_dev_info = sb->s_bdi;
        li->iblock = NULL;
        li->dblock = NULL;
        li->update_cluster = 0;