From: NeilBrown Date: Fri, 16 Jul 2010 09:00:39 +0000 (+0200) Subject: Forward port to 2.6.34 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=a9034c27efeb3e590a79ab967377d55860796fa0;p=LaFS.git Forward port to 2.6.34 Also convert to using kvm for testing - much faster. Signed-off-by: NeilBrown --- diff --git a/Makefile b/Makefile index 1c3f122..11c5ad1 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ lafs-y := super.o io.o roll.o dir.o inode.o index.o block.o file.o link.o dir-av else KERNELDIR := /home/src/lafs-2.6.27 +KERNELDIR := /home/src/lafs-2.6.34/OBJ all:: $(MAKE) -C $(KERNELDIR) ARCH=i386 M=`pwd` nm lafs.o | grep ' T ' | grep -v lafs_ diff --git a/block.c b/block.c index 80e7299..529db5e 100644 --- a/block.c +++ b/block.c @@ -9,6 +9,7 @@ #include "lafs.h" #include /* for try_to_release_page */ +#include /* * Data blocks are stored in a regular address space for the * relevant file. A page may have multiple datablocks, but diff --git a/cluster.c b/cluster.c index 528193d..826be74 100644 --- a/cluster.c +++ b/cluster.c @@ -41,8 +41,9 @@ * addressing for 2^16 entries, which is probably more than we need */ -#include "lafs.h" -#include +#include "lafs.h" +#include +#include static void cluster_flush(struct fs *fs, int cnum); diff --git a/dir.c b/dir.c index 409ecc2..a4f862d 100644 --- a/dir.c +++ b/dir.c @@ -9,6 +9,7 @@ */ #include "lafs.h" +#include #define S_SHIFT 12 diff --git a/file.c b/file.c index d88bcfe..2442b43 100644 --- a/file.c +++ b/file.c @@ -342,7 +342,7 @@ lafs_writepage(struct page *page, struct writeback_control *wbc) if (!b0 || redirty) return 0; - if (wbc->for_writepages && LAFSI(ino)->depth == 0) { + if (LAFSI(ino)->depth == 0) { /* We really want the data to be safe soon, not just * the page to be clean. And the data is in the inode. * So write the inode. diff --git a/index.c b/index.c index 3ddc39b..517b3f2 100644 --- a/index.c +++ b/index.c @@ -10,6 +10,7 @@ #include "lafs.h" #include #include +#include /* * For each index-block there is an 'indexblock' data structure, * and a 'block' of memory, which is a page or part there-of. @@ -1202,7 +1203,7 @@ leaf_lookup(void *bf, int len, u32 startaddr, u32 target, u32 *nextp) len -= target*6; len -= 6; next++; - *nextp = ~0UL; + *nextp = 0xffffffff; while (len >= 6) { p2 = decode48(buf); if (p2) { @@ -1252,14 +1253,14 @@ leaf_lookup(void *bf, int len, u32 startaddr, u32 target, u32 *nextp) if (nextp) { if (lo == len/12) - *nextp = ~0UL; /* next extent */ + *nextp = 0xffffffff; /* next extent */ else { u64 p2; p2 = decode48(cp); elen = decode16(cp); addr = decode32(cp); if (elen == 0) - *nextp = ~0UL; /* no more meaningful + *nextp = 0xffffffff; /* no more meaningful extents*/ else *nextp = addr; diff --git a/inode.c b/inode.c index 234aa8e..2bc79e0 100644 --- a/inode.c +++ b/inode.c @@ -527,13 +527,13 @@ void lafs_inode_init(struct datablock *b, int type, int mode, struct inode *dir) struct timespec now = CURRENT_TIME; l->flags = cpu_to_le16(0); - l->userid = cpu_to_le32(current->fsuid); + l->userid = cpu_to_le32(current->cred->fsuid); if (dir && (dir->i_mode & S_ISGID)) { l->groupid = cpu_to_le32(dir->i_gid); if (type == TypeDir) mode |= S_ISGID; } else - l->groupid = cpu_to_le32(current->fsgid); + l->groupid = cpu_to_le32(current->cred->fsgid); if (LAFSI(dir)->md.file.treeid) l->treeid = cpu_to_le32(LAFSI(dir)->md.file.treeid); else diff --git a/io.c b/io.c index 1957113..abecfa8 100644 --- a/io.c +++ b/io.c @@ -55,7 +55,7 @@ lafs_sync_page_io(struct block_device *bdev, sector_t sector, struct completion event; int ret; - rw |= (1 << BIO_RW_SYNC); + rw |= (1 << BIO_RW_UNPLUG); bio->bi_bdev = bdev; bio->bi_sector = sector; @@ -110,7 +110,7 @@ async_page_io(struct block_device *bdev, sector_t sector, int offset, int size, { struct bio *bio = bio_alloc(GFP_NOIO, 1); - rw |= (1 << BIO_RW_SYNC); + rw |= (1 << BIO_RW_UNPLUG); bio->bi_bdev = bdev; bio->bi_sector = sector; @@ -165,7 +165,7 @@ void lafs_super_write(struct fs *fs, int dev, u64 addr, char *buf, int size) { struct bio *bio = bio_alloc(GFP_NOIO, 1); - int rw = WRITE | (1 << BIO_RW_SYNC); + int rw = WRITE | (1 << BIO_RW_UNPLUG); bio->bi_bdev = fs->devs[dev].sb->s_bdev; bio->bi_sector = addr; diff --git a/modify.c b/modify.c index 0a03df8..ef0010f 100644 --- a/modify.c +++ b/modify.c @@ -1228,8 +1228,9 @@ static int do_incorporate_leaf(struct fs *fs, struct indexblock *ib, ? add_extent : add_indirect, &layout); break; + default: BUG(); } - dprintk("walk_leaf only got as far as %d\n", (int)next); + dprintk("walk_leaf only got as far as %d\n", (int)layout.nextaddr); // print_index(ibuf+offset, ib->b.fileaddr, len); if (ok) { /* it all fit perfectly. @@ -1368,7 +1369,7 @@ static int do_incorporate_leaf(struct fs *fs, struct indexblock *ib, if (slen && layout.data > sbuf) { printk("slen=%d ld-sb=%d layout.data=%p sbuf=%p " "buf=%p ibuf=%p len=%d\n", - slen, layout.data-sbuf, layout.data, sbuf, + slen, (int)(layout.data-sbuf), layout.data, sbuf, buf, ibuf, len); } LAFS_BUG(slen && layout.data > sbuf, &ib->b); diff --git a/roll.c b/roll.c index 42882c7..3417129 100644 --- a/roll.c +++ b/roll.c @@ -9,6 +9,7 @@ */ #include "lafs.h" +#include static int roll_valid(struct fs *fs, struct cluster_head *ch, unsigned long long addr) diff --git a/segments.c b/segments.c index d0e40ca..eb07c77 100644 --- a/segments.c +++ b/segments.c @@ -71,9 +71,10 @@ * on the segment summary block through this structure */ -#include "lafs.h" -#include -#include +#include "lafs.h" +#include +#include +#include struct segsum { u32 segnum; diff --git a/super.c b/super.c index 6179855..3fc68e5 100644 --- a/super.c +++ b/super.c @@ -12,6 +12,7 @@ #include #include #include +#include static struct super_operations lafs_sops; static const struct export_operations lafs_export_ops; @@ -304,7 +305,7 @@ lafs_fill_super(struct super_block *sb, void *opv, int silent) BUG_ON(dv->devblock); BUG_ON(dv->stateblock); - n = queue_hardsect_size(sb->s_bdev->bd_disk->queue); + n = queue_logical_block_size(sb->s_bdev->bd_disk->queue); if (n < LAFS_DEVBLK_SIZE) n = LAFS_DEVBLK_SIZE; BUG_ON(n > PAGE_SIZE); @@ -366,7 +367,7 @@ lafs_fill_super(struct super_block *sb, void *opv, int silent) */ n = le32_to_cpu(1<devblock->statebits); if ((n & (n-1)) || - n < queue_hardsect_size(sb->s_bdev->bd_disk->queue) || + n < queue_logical_block_size(sb->s_bdev->bd_disk->queue) || n > 128*1024) { printk(KERN_ERR "LaFS: statesize of %u not acceptable.\n", n); err = -EINVAL; @@ -973,15 +974,9 @@ static struct dentry *lafs_get_parent(struct dentry *child) { ino_t inum = LAFSI(child->d_inode)->md.file.parent; struct inode *inode = lafs_iget(child->d_inode->i_sb, inum, SYNC); - struct dentry *parent; if (IS_ERR(inode)) return ERR_CAST(inode); - parent = d_alloc_anon(inode); - if (!parent) { - iput(inode); - parent = ERR_PTR(-ENOMEM); - } - return parent; + return d_obtain_alias(inode); } static const struct export_operations lafs_export_ops = { @@ -1166,5 +1161,6 @@ static int get_dump(char *buffer, struct kernel_param *kp) return strlen(buffer); } -module_param_call(dump, do_dump, get_dump, 0, 0775); +int arg; +module_param_call(dump, do_dump, get_dump, &arg, 0775); #endif diff --git a/test/go b/test/go index 13bf6a1..a49f49c 100644 --- a/test/go +++ b/test/go @@ -12,15 +12,15 @@ rm -f lafs.ko rmmod lafs.ko tftp 10.0.2.2 -m binary -c get /lafs.ko insmod lafs.ko lafs_trace=0 -#mount -r -t lafs -o 'dev=/dev/hdc' /dev/hdb /mnt/1 -mount -t lafs /dev/hdb /mnt/1 +#mount -r -t lafs -o 'dev=/dev/sdc' /dev/sdb /mnt/1 +mount -t lafs /dev/sdb /mnt/1 #mount -r -t lafs_snap -o snapshot=first /mnt/1 /mnt/2 #mount -r -t lafs_snap -o snapshot=second /mnt/1 /mnt/3 #mount -r -t lafs -o 'snapshot=first /mnt/1 /mnt/2 ls /mnt/1; ls -ia /mnt/1 -#mount /dev/hdb /mnt/2 +#mount /dev/sdb /mnt/2 #cat /mnt/1/17 md5sum /mnt/1/afile echo 'db53....4f6a' diff --git a/test/runtty b/test/runtty index 77e3b79..b92439f 100644 --- a/test/runtty +++ b/test/runtty @@ -13,9 +13,9 @@ rm -f /tmp/tftp ln -s $dir /tmp/tftp # -serial stdio or -nographic # change tty choice in 'go' too. -qemu -hda hda -hdb $dir/../../code2/fred -hdc $dir/../../code2/frog \ +kvm -hda hda -hdb $dir/../../code2/fred -hdc $dir/../../code2/frog \ -no-reboot \ -net nic,model=ne2k_pci -net user \ -m 256 -nographic \ - -kernel /home/src/lafs-2.6.27/arch/i386/boot/bzImage \ - -append "root=/dev/hda1 console=ttyS0" -tftp /tmp/tftp + -kernel /home/src/lafs-2.6.34/OBJ/arch/x86/boot/bzImage \ + -append "root=/dev/sda1 console=ttyS0" -tftp /tmp/tftp