* [PATCH] Add compability for kernels >=2.6.27-rc1
@ 2008-07-30 19:11 Sven Wegener
2008-07-30 19:56 ` Jens Axboe
0 siblings, 1 reply; 10+ messages in thread
From: Sven Wegener @ 2008-07-30 19:11 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs
Add a couple of #if's to follow API changes.
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
---
extent_io.c | 16 ++++++++++++++++
file.c | 4 ++++
inode.c | 12 ++++++++++--
3 files changed, 30 insertions(+), 2 deletions(-)
Having passed the rc1 mark the API changes should be finished.
Other #if in the source use >version instead of >=version+1, so I use them
too.
Patch is against the current unstable repository, but can applied with a
slight modification (extent_io.c) to the stable repository too.
diff -r 59ec68fb1540 extent_io.c
--- a/extent_io.c Wed Jul 30 10:29:12 2008 -0400
+++ b/extent_io.c Wed Jul 30 19:00:28 2008 +0000
@@ -2649,9 +2649,17 @@
mapping = eb->first_page->mapping;
if (!mapping)
return NULL;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
+ spin_lock_irq(&mapping->tree_lock);
+#else
read_lock_irq(&mapping->tree_lock);
+#endif
p = radix_tree_lookup(&mapping->page_tree, i);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
+ spin_unlock_irq(&mapping->tree_lock);
+#else
read_unlock_irq(&mapping->tree_lock);
+#endif
return p;
}
@@ -2843,13 +2851,21 @@
}
}
clear_page_dirty_for_io(page);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
+ spin_lock_irq(&page->mapping->tree_lock);
+#else
read_lock_irq(&page->mapping->tree_lock);
+#endif
if (!PageDirty(page)) {
radix_tree_tag_clear(&page->mapping->page_tree,
page_index(page),
PAGECACHE_TAG_DIRTY);
}
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
+ spin_unlock_irq(&page->mapping->tree_lock);
+#else
read_unlock_irq(&page->mapping->tree_lock);
+#endif
unlock_page(page);
}
return 0;
diff -r 59ec68fb1540 file.c
--- a/file.c Wed Jul 30 10:29:12 2008 -0400
+++ b/file.c Wed Jul 30 19:00:28 2008 +0000
@@ -886,7 +886,11 @@
#ifdef REMOVE_SUID_PATH
err = remove_suid(&file->f_path);
#else
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
+ err = file_remove_suid(file);
+#else
err = remove_suid(fdentry(file));
+#endif
#endif
if (err)
goto out_nolock;
diff -r 59ec68fb1540 inode.c
--- a/inode.c Wed Jul 30 10:29:12 2008 -0400
+++ b/inode.c Wed Jul 30 19:00:28 2008 +0000
@@ -3293,7 +3293,9 @@
kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode));
}
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
+static void init_once(void *foo)
+#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
static void init_once(struct kmem_cache * cachep, void *foo)
#else
static void init_once(void * foo, struct kmem_cache * cachep,
@@ -3321,7 +3323,9 @@
struct kmem_cache *btrfs_cache_create(const char *name, size_t size,
unsigned long extra_flags,
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
+ void (*ctor)(void *)
+#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
void (*ctor)(struct kmem_cache *, void *)
#else
void (*ctor)(void *, struct kmem_cache *,
@@ -3561,8 +3565,12 @@
return __set_page_dirty_nobuffers(page);
}
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
+static int btrfs_permission(struct inode *inode, int mask)
+#else
static int btrfs_permission(struct inode *inode, int mask,
struct nameidata *nd)
+#endif
{
if (btrfs_test_flag(inode, READONLY) && (mask & MAY_WRITE))
return -EACCES;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add compability for kernels >=2.6.27-rc1
2008-07-30 19:11 [PATCH] Add compability for kernels >=2.6.27-rc1 Sven Wegener
@ 2008-07-30 19:56 ` Jens Axboe
2008-07-30 20:11 ` Chris Mason
0 siblings, 1 reply; 10+ messages in thread
From: Jens Axboe @ 2008-07-30 19:56 UTC (permalink / raw)
To: Sven Wegener; +Cc: Chris Mason, linux-btrfs
On Wed, Jul 30 2008, Sven Wegener wrote:
> Add a couple of #if's to follow API changes.
>
> Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
> ---
> extent_io.c | 16 ++++++++++++++++
> file.c | 4 ++++
> inode.c | 12 ++++++++++--
> 3 files changed, 30 insertions(+), 2 deletions(-)
>
> Having passed the rc1 mark the API changes should be finished.
>
> Other #if in the source use >version instead of >=version+1, so I use them
> too.
>
> Patch is against the current unstable repository, but can applied with a
> slight modification (extent_io.c) to the stable repository too.
>
> diff -r 59ec68fb1540 extent_io.c
> --- a/extent_io.c Wed Jul 30 10:29:12 2008 -0400
> +++ b/extent_io.c Wed Jul 30 19:00:28 2008 +0000
> @@ -2649,9 +2649,17 @@
> mapping = eb->first_page->mapping;
> if (!mapping)
> return NULL;
> +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
> + spin_lock_irq(&mapping->tree_lock);
> +#else
> read_lock_irq(&mapping->tree_lock);
> +#endif
> p = radix_tree_lookup(&mapping->page_tree, i);
> +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
> + spin_unlock_irq(&mapping->tree_lock);
> +#else
> read_unlock_irq(&mapping->tree_lock);
> +#endif
> return p;
> }
For btrfs's usage, it should be safe with a simple rcu_read_lock(), if
the return is referenced safely.
--
Jens Axboe
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add compability for kernels >=2.6.27-rc1
2008-07-30 19:56 ` Jens Axboe
@ 2008-07-30 20:11 ` Chris Mason
2008-07-30 20:13 ` Jens Axboe
0 siblings, 1 reply; 10+ messages in thread
From: Chris Mason @ 2008-07-30 20:11 UTC (permalink / raw)
To: Jens Axboe; +Cc: Sven Wegener, linux-btrfs
On Wed, 2008-07-30 at 21:56 +0200, Jens Axboe wrote:
> On Wed, Jul 30 2008, Sven Wegener wrote:
> > Add a couple of #if's to follow API changes.
> >
> > Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
> > ---
> > extent_io.c | 16 ++++++++++++++++
> > file.c | 4 ++++
> > inode.c | 12 ++++++++++--
> > 3 files changed, 30 insertions(+), 2 deletions(-)
> >
> > Having passed the rc1 mark the API changes should be finished.
> >
> > Other #if in the source use >version instead of >=version+1, so I use them
> > too.
> >
> > Patch is against the current unstable repository, but can applied with a
> > slight modification (extent_io.c) to the stable repository too.
> >
> > diff -r 59ec68fb1540 extent_io.c
> > --- a/extent_io.c Wed Jul 30 10:29:12 2008 -0400
> > +++ b/extent_io.c Wed Jul 30 19:00:28 2008 +0000
> > @@ -2649,9 +2649,17 @@
> > mapping = eb->first_page->mapping;
> > if (!mapping)
> > return NULL;
> > +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
> > + spin_lock_irq(&mapping->tree_lock);
> > +#else
> > read_lock_irq(&mapping->tree_lock);
> > +#endif
> > p = radix_tree_lookup(&mapping->page_tree, i);
> > +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
> > + spin_unlock_irq(&mapping->tree_lock);
> > +#else
> > read_unlock_irq(&mapping->tree_lock);
> > +#endif
> > return p;
> > }
>
> For btrfs's usage, it should be safe with a simple rcu_read_lock(), if
> the return is referenced safely.
>
This btrfs code is basically a find_get_page without the get. It should
only be called when I know I already have a reference on the page.
-chris
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add compability for kernels >=2.6.27-rc1
2008-07-30 20:11 ` Chris Mason
@ 2008-07-30 20:13 ` Jens Axboe
2008-07-30 20:43 ` Chris Mason
0 siblings, 1 reply; 10+ messages in thread
From: Jens Axboe @ 2008-07-30 20:13 UTC (permalink / raw)
To: Chris Mason; +Cc: Sven Wegener, linux-btrfs
On Wed, Jul 30 2008, Chris Mason wrote:
> On Wed, 2008-07-30 at 21:56 +0200, Jens Axboe wrote:
> > On Wed, Jul 30 2008, Sven Wegener wrote:
> > > Add a couple of #if's to follow API changes.
> > >
> > > Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
> > > ---
> > > extent_io.c | 16 ++++++++++++++++
> > > file.c | 4 ++++
> > > inode.c | 12 ++++++++++--
> > > 3 files changed, 30 insertions(+), 2 deletions(-)
> > >
> > > Having passed the rc1 mark the API changes should be finished.
> > >
> > > Other #if in the source use >version instead of >=version+1, so I use them
> > > too.
> > >
> > > Patch is against the current unstable repository, but can applied with a
> > > slight modification (extent_io.c) to the stable repository too.
> > >
> > > diff -r 59ec68fb1540 extent_io.c
> > > --- a/extent_io.c Wed Jul 30 10:29:12 2008 -0400
> > > +++ b/extent_io.c Wed Jul 30 19:00:28 2008 +0000
> > > @@ -2649,9 +2649,17 @@
> > > mapping = eb->first_page->mapping;
> > > if (!mapping)
> > > return NULL;
> > > +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
> > > + spin_lock_irq(&mapping->tree_lock);
> > > +#else
> > > read_lock_irq(&mapping->tree_lock);
> > > +#endif
> > > p = radix_tree_lookup(&mapping->page_tree, i);
> > > +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
> > > + spin_unlock_irq(&mapping->tree_lock);
> > > +#else
> > > read_unlock_irq(&mapping->tree_lock);
> > > +#endif
> > > return p;
> > > }
> >
> > For btrfs's usage, it should be safe with a simple rcu_read_lock(), if
> > the return is referenced safely.
> >
>
> This btrfs code is basically a find_get_page without the get. It should
> only be called when I know I already have a reference on the page.
Then it's definitely safe ;-)
--
Jens Axboe
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add compability for kernels >=2.6.27-rc1
2008-07-30 20:13 ` Jens Axboe
@ 2008-07-30 20:43 ` Chris Mason
2008-07-31 19:27 ` David Woodhouse
0 siblings, 1 reply; 10+ messages in thread
From: Chris Mason @ 2008-07-30 20:43 UTC (permalink / raw)
To: Jens Axboe; +Cc: Sven Wegener, linux-btrfs
On Wed, 2008-07-30 at 22:13 +0200, Jens Axboe wrote:
[ rcu page cache ]
> > > For btrfs's usage, it should be safe with a simple rcu_read_lock(), if
> > > the return is referenced safely.
> > >
> >
> > This btrfs code is basically a find_get_page without the get. It should
> > only be called when I know I already have a reference on the page.
>
> Then it's definitely safe ;-)
>
Yeah, I'm testing on the latest git now and it all seems ok. I'll push
this out, thanks Sven.
-chris
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add compability for kernels >=2.6.27-rc1
2008-07-30 20:43 ` Chris Mason
@ 2008-07-31 19:27 ` David Woodhouse
2008-07-31 19:37 ` Chris Mason
0 siblings, 1 reply; 10+ messages in thread
From: David Woodhouse @ 2008-07-31 19:27 UTC (permalink / raw)
To: Chris Mason; +Cc: Jens Axboe, Sven Wegener, linux-btrfs
On Wed, 2008-07-30 at 16:43 -0400, Chris Mason wrote:
> On Wed, 2008-07-30 at 22:13 +0200, Jens Axboe wrote:
>
> [ rcu page cache ]
>
> > > > For btrfs's usage, it should be safe with a simple rcu_read_lock(), if
> > > > the return is referenced safely.
> > > >
> > >
> > > This btrfs code is basically a find_get_page without the get. It should
> > > only be called when I know I already have a reference on the page.
> >
> > Then it's definitely safe ;-)
> >
>
> Yeah, I'm testing on the latest git now and it all seems ok. I'll push
> this out, thanks Sven.
Seems to crash for me with Linus' current tree. I thought it was
something to do with my fixes for NFS export, but now I've hooked up a
serial console and managed to catch it, I suspect not...
BUG: unable to handle kernel paging request at ffff880107c2aa00
IP: [<ffffffffa03e73bc>] end_bio_extent_writepage+0x1f4/0x29c [btrfs]
PGD 202063 PUD c067 PMD 10a844163 PTE 8000000107c2a160
Oops: 0000 [1] SMP DEBUG_PAGEALLOC
CPU 3
Modules linked in: btrfs libcrc32c nfsd lockd nfs_acl auth_rpcgss exportfs mtdram jffs2 mtd zlib_deflate i915 drm bridge stp bnep rfcomm l2cap bluetooth fuse sunrpc ipv6 cpufreq_ondemand acpi_cpufreq freq_table dm_mirror dm_log dm_multipath dm_mod snd_pcsp snd_hda_intel snd_seq_dummy snd_seq_oss snd_seq_midi_event snd_seq snd_seq_device sr_mod cdrom snd_pcm_oss snd_mixer_oss firewire_ohci firewire_core snd_pcm floppy i2c_i801 i2c_core snd_timer pata_marvell crc_itu_t iTCO_wdt e1000e snd_hwdep snd_page_alloc ata_generic iTCO_vendor_support pata_acpi snd soundcore ahci ext3 jbd mbcache uhci_hcd ohci_hcd ehci_hcd [last unloaded: jffs2]
Pid: 3273, comm: btrfs Tainted: G W 2.6.27-rc1 #1
RIP: 0010:[<ffffffffa03e73bc>] [<ffffffffa03e73bc>] end_bio_extent_writepage+0x1f4/0x29c [btrfs]
RSP: 0018:ffff88010e581e10 EFLAGS: 00010082
RAX: 0000000000000002 RBX: ffff880107c2aae0 RCX: 0000000000000001
RDX: 0000000000000005 RSI: ffff880107c2aae0 RDI: ffffffff810644db
RBP: ffff88010e581e80 R08: ffff88010e581cb0 R09: ffff88000000d000
R10: 0000000000000002 R11: ffff88010e581d30 R12: ffff880107c2aa08
R13: ffff880107c2a9f8 R14: 0000000000080000 R15: ffffe200063eb920
FS: 0000000000000000(0000) GS:ffff880127c41e10(0000) knlGS:0000000000000000
CS: 0010 DS: 0018 ES: 0018 CR0: 000000008005003b
CR2: ffff880107c2aa00 CR3: 000000010b5b0000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process btrfs (pid: 3273, threadinfo ffff88010e580000, task ffff88010b190000)
Stack: ffff88010b58e540 0000000000001000 ffff88010c60f1d8 0000000181065346
ffff88010a995d70 ffff88010c60f1b8 0000000000080000 0000000000000282
000000010e581e90 0000000000000000 ffff88010b5ff620 ffff88010b58e540
Call Trace:
[<ffffffff810f1aa4>] bio_endio+0x2f/0x31
[<ffffffffa03d0bbf>] end_workqueue_fn+0x108/0x114 [btrfs]
[<ffffffffa03ebdc8>] worker_loop+0x6b/0x14e [btrfs]
[<ffffffffa03ebd5d>] ? worker_loop+0x0/0x14e [btrfs]
[<ffffffff81057b34>] kthread+0x4e/0x7b
[<ffffffff81011849>] child_rip+0xa/0x11
[<ffffffff81010b5e>] ? restore_args+0x0/0x30
[<ffffffff81057ae6>] ? kthread+0x0/0x7b
[<ffffffff8101183f>] ? child_rip+0x0/0x11
Code: de e8 15 d5 ff ff 4c 39 75 c0 74 1a 73 13 be d5 05 00 00 48 c7 c7 fc fd 3e a0 e8 1c c5 c5 e0 eb 05 4d 85 e4 75 a4 4d 85 ed 74 19 <49> 8b 45 08 48 ff c0 4c 39 f0 75 0a 41 f6 85 80 00 00 00 02 75
RIP [<ffffffffa03e73bc>] end_bio_extent_writepage+0x1f4/0x29c [btrfs]
RSP <ffff88010e581e10>
CR2: ffff880107c2aa00
---[ end trace 4eaa2a86a8e2da22 ]---
BUG: unable to handle kernel paging request at ffff880107ced918
IP: [<ffffffffa03e73bc>] end_bio_extent_writepage+0x1f4/0x29c [btrfs]
PGD 202063 PUD c067 PMD 10a844163 PTE 8000000107ced160
Oops: 0000 [2] SMP DEBUG_PAGEALLOC
CPU 3
Modules linked in: btrfs libcrc32c nfsd lockd nfs_acl auth_rpcgss exportfs mtdram jffs2 mtd zlib_deflate i915 drm bridge stp bnep rfcomm l2cap bluetooth fuse sunrpc ipv6 cpufreq_ondemand acpi_cpufreq freq_table dm_mirror dm_log dm_multipath dm_mod snd_pcsp snd_hda_intel snd_seq_dummy snd_seq_oss snd_seq_midi_event snd_seq snd_seq_device sr_mod cdrom snd_pcm_oss snd_mixer_oss firewire_ohci firewire_core snd_pcm floppy i2c_i801 i2c_core snd_timer pata_marvell crc_itu_t iTCO_wdt e1000e snd_hwdep snd_page_alloc ata_generic iTCO_vendor_support pata_acpi snd soundcore ahci ext3 jbd mbcache uhci_hcd ohci_hcd ehci_hcd [last unloaded: jffs2]
Pid: 3274, comm: btrfs Tainted: G D W 2.6.27-rc1 #1
RIP: 0010:[<ffffffffa03e73bc>] [<ffffffffa03e73bc>] end_bio_extent_writepage+0x1f4/0x29c [btrfs]
RSP: 0018:ffff88010b95fe10 EFLAGS: 00010082
RAX: 0000000000000002 RBX: ffff880107ced9f8 RCX: 0000000000000001
RDX: 0000000000000005 RSI: ffff880107ced9f8 RDI: ffffffff810644db
RBP: ffff88010b95fe80 R08: ffff88010b95fcb0 R09: ffff88000000d000
R10: 0000000000000002 R11: ffff88010b95fd30 R12: ffff880107ced920
R13: ffff880107ced910 R14: 0000000000080000 R15: ffffe20006321d20
FS: 0000000000000000(0000) GS:ffff880127c41e10(0000) knlGS:0000000000000000
CS: 0010 DS: 0018 ES: 0018 CR0: 000000008005003b
CR2: ffff880107ced918 CR3: 000000010b5b0000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process btrfs (pid: 3274, threadinfo ffff88010b95e000, task ffff88010b192580)
Stack: ffff88010a879240 0000000000001000 ffff88010c7a71d8 0000000181065346
ffff88010a9e3b70 ffff88010c7a71b8 0000000000080000 0000000000000282
000000010b95fe90 0000000000000000 ffff88010e59d8c0 ffff88010a879240
Call Trace:
[<ffffffff810f1aa4>] bio_endio+0x2f/0x31
[<ffffffffa03d0bbf>] end_workqueue_fn+0x108/0x114 [btrfs]
[<ffffffffa03ebdc8>] worker_loop+0x6b/0x14e [btrfs]
[<ffffffffa03ebd5d>] ? worker_loop+0x0/0x14e [btrfs]
[<ffffffff81057b34>] kthread+0x4e/0x7b
[<ffffffff81011849>] child_rip+0xa/0x11
[<ffffffff81010b5e>] ? restore_args+0x0/0x30
[<ffffffff81057ae6>] ? kthread+0x0/0x7b
[<ffffffff8101183f>] ? child_rip+0x0/0x11
Code: de e8 15 d5 ff ff 4c 39 75 c0 74 1a 73 13 be d5 05 00 00 48 c7 c7 fc fd 3e a0 e8 1c c5 c5 e0 eb 05 4d 85 e4 75 a4 4d 85 ed 74 19 <49> 8b 45 08 48 ff c0 4c 39 f0 75 0a 41 f6 85 80 00 00 00 02 75
RIP [<ffffffffa03e73bc>] end_bio_extent_writepage+0x1f4/0x29c [btrfs]
RSP <ffff88010b95fe10>
CR2: ffff880107ced918
---[ end trace 4eaa2a86a8e2da22 ]---
--
David Woodhouse Open Source Technology Centre
David.Woodhouse@intel.com Intel Corporation
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add compability for kernels >=2.6.27-rc1
2008-07-31 19:27 ` David Woodhouse
@ 2008-07-31 19:37 ` Chris Mason
2008-07-31 19:52 ` David Woodhouse
2008-08-19 14:51 ` David Woodhouse
0 siblings, 2 replies; 10+ messages in thread
From: Chris Mason @ 2008-07-31 19:37 UTC (permalink / raw)
To: David Woodhouse; +Cc: Jens Axboe, Sven Wegener, linux-btrfs
On Thu, 2008-07-31 at 20:27 +0100, David Woodhouse wrote:
> On Wed, 2008-07-30 at 16:43 -0400, Chris Mason wrote:
> > On Wed, 2008-07-30 at 22:13 +0200, Jens Axboe wrote:
> >
> > [ rcu page cache ]
> >
> > > > > For btrfs's usage, it should be safe with a simple rcu_read_lock(), if
> > > > > the return is referenced safely.
> > > > >
> > > >
> > > > This btrfs code is basically a find_get_page without the get. It should
> > > > only be called when I know I already have a reference on the page.
> > >
> > > Then it's definitely safe ;-)
> > >
> >
> > Yeah, I'm testing on the latest git now and it all seems ok. I'll push
> > this out, thanks Sven.
>
> Seems to crash for me with Linus' current tree. I thought it was
> something to do with my fixes for NFS export, but now I've hooked up a
> serial console and managed to catch it, I suspect not...
>
> BUG: unable to handle kernel paging request at ffff880107c2aa00
> IP: [<ffffffffa03e73bc>] end_bio_extent_writepage+0x1f4/0x29c [btrfs]
If you can reliably reproduce this, please try with the spin locks
instead of rcu read locks. What were you doing at the time?
-chris
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add compability for kernels >=2.6.27-rc1
2008-07-31 19:37 ` Chris Mason
@ 2008-07-31 19:52 ` David Woodhouse
2008-08-19 14:51 ` David Woodhouse
1 sibling, 0 replies; 10+ messages in thread
From: David Woodhouse @ 2008-07-31 19:52 UTC (permalink / raw)
To: Chris Mason; +Cc: Jens Axboe, Sven Wegener, linux-btrfs
On Thu, 2008-07-31 at 15:37 -0400, Chris Mason wrote:
> If you can reliably reproduce this, please try with the spin locks
> instead of rcu read locks. What were you doing at the time?
Just copying a bunch of files into it so that I could test NFS
readdirplus with the following:
http://git.infradead.org/users/dwmw2/nfsexport-2.6.git
http://git.infradead.org/users/dwmw2/btrfs-kernel-unstable.git
I'll revert to your version to make 100% sure it wasn't the iget or NFS
patches. And I think I need to update, too.
--
dwmw2
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add compability for kernels >=2.6.27-rc1
2008-07-31 19:37 ` Chris Mason
2008-07-31 19:52 ` David Woodhouse
@ 2008-08-19 14:51 ` David Woodhouse
2008-08-19 16:30 ` Chris Mason
1 sibling, 1 reply; 10+ messages in thread
From: David Woodhouse @ 2008-08-19 14:51 UTC (permalink / raw)
To: Chris Mason; +Cc: Jens Axboe, Sven Wegener, linux-btrfs
On Thu, 2008-07-31 at 15:37 -0400, Chris Mason wrote:
> > BUG: unable to handle kernel paging request at ffff880107c2aa00
> > IP: [<ffffffffa03e73bc>] end_bio_extent_writepage+0x1f4/0x29c
> [btrfs]
>
> If you can reliably reproduce this, please try with the spin locks
> instead of rcu read locks. What were you doing at the time?
Just using CONFIG_DEBUG_PAGEALLOC and dirtying a bunch of pages from
different inodes seems enough. Another patch to add to my collection at
git.infradead.org/users/dwmw2/btrfs-kernel-unstable.git ...
From: David Woodhouse <David.Woodhouse@intel.com>
Date: Tue, 19 Aug 2008 15:45:16 +0100
Subject: [PATCH] Remove broken optimisations in end_bio functions.
These ended up freeing objects while they were still using them. Under
guidance from Chris, just rip out the 'clever' bits and do things the
simple way.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
extent_io.c | 159 ++++++++---------------------------------------------------
1 files changed, 21 insertions(+), 138 deletions(-)
diff --git a/extent_io.c b/extent_io.c
index f46f886..83ba0c3 100644
--- a/extent_io.c
+++ b/extent_io.c
@@ -15,6 +15,8 @@
#include "extent_io.h"
#include "extent_map.h"
#include "compat.h"
+#include "ctree.h"
+#include "btrfs_inode.h"
/* temporary define until extent_map moves out of btrfs */
struct kmem_cache *btrfs_cache_create(const char *name, size_t size,
@@ -1394,15 +1396,11 @@ static int end_bio_extent_writepage(struct bio *bio,
{
int uptodate = err == 0;
struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
- struct extent_state *state = bio->bi_private;
- struct extent_io_tree *tree = state->tree;
- struct rb_node *node;
+ struct extent_io_tree *tree;
u64 start;
u64 end;
- u64 cur;
int whole_page;
int ret;
- unsigned long flags;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
if (bio->bi_size)
@@ -1410,6 +1408,8 @@ static int end_bio_extent_writepage(struct bio *bio,
#endif
do {
struct page *page = bvec->bv_page;
+ tree = &BTRFS_I(page->mapping->host)->io_tree;
+
start = ((u64)page->index << PAGE_CACHE_SHIFT) +
bvec->bv_offset;
end = start + bvec->bv_len - 1;
@@ -1423,7 +1423,7 @@ static int end_bio_extent_writepage(struct bio *bio,
prefetchw(&bvec->bv_page->flags);
if (tree->ops && tree->ops->writepage_end_io_hook) {
ret = tree->ops->writepage_end_io_hook(page, start,
- end, state, uptodate);
+ end, NULL, uptodate);
if (ret)
uptodate = 0;
}
@@ -1431,9 +1431,8 @@ static int end_bio_extent_writepage(struct bio *bio,
if (!uptodate && tree->ops &&
tree->ops->writepage_io_failed_hook) {
ret = tree->ops->writepage_io_failed_hook(bio, page,
- start, end, state);
+ start, end, NULL);
if (ret == 0) {
- state = NULL;
uptodate = (err == 0);
continue;
}
@@ -1445,68 +1444,7 @@ static int end_bio_extent_writepage(struct bio *bio,
SetPageError(page);
}
- /*
- * bios can get merged in funny ways, and so we need to
- * be careful with the state variable. We know the
- * state won't be merged with others because it has
- * WRITEBACK set, but we can't be sure each biovec is
- * sequential in the file. So, if our cached state
- * doesn't match the expected end, search the tree
- * for the correct one.
- */
-
- spin_lock_irqsave(&tree->lock, flags);
- if (!state || state->end != end) {
- state = NULL;
- node = __etree_search(tree, start, NULL, NULL);
- if (node) {
- state = rb_entry(node, struct extent_state,
- rb_node);
- if (state->end != end ||
- !(state->state & EXTENT_WRITEBACK))
- state = NULL;
- }
- if (!state) {
- spin_unlock_irqrestore(&tree->lock, flags);
- clear_extent_writeback(tree, start,
- end, GFP_ATOMIC);
- goto next_io;
- }
- }
- cur = end;
- while(1) {
- struct extent_state *clear = state;
- cur = state->start;
- node = rb_prev(&state->rb_node);
- if (node) {
- state = rb_entry(node,
- struct extent_state,
- rb_node);
- } else {
- state = NULL;
- }
-
- clear_state_bit(tree, clear, EXTENT_WRITEBACK,
- 1, 0);
- if (cur == start)
- break;
- if (cur < start) {
- WARN_ON(1);
- break;
- }
- if (!node)
- break;
- }
- /* before releasing the lock, make sure the next state
- * variable has the expected bits set and corresponds
- * to the correct offsets in the file
- */
- if (state && (state->end + 1 != start ||
- !(state->state & EXTENT_WRITEBACK))) {
- state = NULL;
- }
- spin_unlock_irqrestore(&tree->lock, flags);
-next_io:
+ clear_extent_writeback(tree, start, end, GFP_ATOMIC);
if (whole_page)
end_page_writeback(page);
@@ -1539,13 +1477,9 @@ static int end_bio_extent_readpage(struct bio *bio,
{
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
- struct extent_state *state = bio->bi_private;
- struct extent_io_tree *tree = state->tree;
- struct rb_node *node;
+ struct extent_io_tree *tree;
u64 start;
u64 end;
- u64 cur;
- unsigned long flags;
int whole_page;
int ret;
@@ -1556,6 +1490,8 @@ static int end_bio_extent_readpage(struct bio *bio,
do {
struct page *page = bvec->bv_page;
+ tree = &BTRFS_I(page->mapping->host)->io_tree;
+
start = ((u64)page->index << PAGE_CACHE_SHIFT) +
bvec->bv_offset;
end = start + bvec->bv_len - 1;
@@ -1570,80 +1506,26 @@ static int end_bio_extent_readpage(struct bio *bio,
if (uptodate && tree->ops && tree->ops->readpage_end_io_hook) {
ret = tree->ops->readpage_end_io_hook(page, start, end,
- state);
+ NULL);
if (ret)
uptodate = 0;
}
if (!uptodate && tree->ops &&
tree->ops->readpage_io_failed_hook) {
ret = tree->ops->readpage_io_failed_hook(bio, page,
- start, end, state);
+ start, end, NULL);
if (ret == 0) {
- state = NULL;
uptodate =
test_bit(BIO_UPTODATE, &bio->bi_flags);
continue;
}
}
- spin_lock_irqsave(&tree->lock, flags);
- if (!state || state->end != end) {
- state = NULL;
- node = __etree_search(tree, start, NULL, NULL);
- if (node) {
- state = rb_entry(node, struct extent_state,
- rb_node);
- if (state->end != end ||
- !(state->state & EXTENT_LOCKED))
- state = NULL;
- }
- if (!state) {
- spin_unlock_irqrestore(&tree->lock, flags);
- if (uptodate)
- set_extent_uptodate(tree, start, end,
- GFP_ATOMIC);
- unlock_extent(tree, start, end, GFP_ATOMIC);
- goto next_io;
- }
- }
+ if (uptodate)
+ set_extent_uptodate(tree, start, end,
+ GFP_ATOMIC);
+ unlock_extent(tree, start, end, GFP_ATOMIC);
- cur = end;
- while(1) {
- struct extent_state *clear = state;
- cur = state->start;
- node = rb_prev(&state->rb_node);
- if (node) {
- state = rb_entry(node,
- struct extent_state,
- rb_node);
- } else {
- state = NULL;
- }
- if (uptodate) {
- set_state_cb(tree, clear, EXTENT_UPTODATE);
- clear->state |= EXTENT_UPTODATE;
- }
- clear_state_bit(tree, clear, EXTENT_LOCKED,
- 1, 0);
- if (cur == start)
- break;
- if (cur < start) {
- WARN_ON(1);
- break;
- }
- if (!node)
- break;
- }
- /* before releasing the lock, make sure the next state
- * variable has the expected bits set and corresponds
- * to the correct offsets in the file
- */
- if (state && (state->end + 1 != start ||
- !(state->state & EXTENT_LOCKED))) {
- state = NULL;
- }
- spin_unlock_irqrestore(&tree->lock, flags);
-next_io:
if (whole_page) {
if (uptodate) {
SetPageUptodate(page);
@@ -1683,8 +1565,7 @@ static int end_bio_extent_preparewrite(struct bio *bio,
{
const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
- struct extent_state *state = bio->bi_private;
- struct extent_io_tree *tree = state->tree;
+ struct extent_io_tree *tree;
u64 start;
u64 end;
@@ -1695,6 +1576,8 @@ static int end_bio_extent_preparewrite(struct bio *bio,
do {
struct page *page = bvec->bv_page;
+ tree = &BTRFS_I(page->mapping->host)->io_tree;
+
start = ((u64)page->index << PAGE_CACHE_SHIFT) +
bvec->bv_offset;
end = start + bvec->bv_len - 1;
@@ -1765,7 +1648,7 @@ static int submit_one_bio(int rw, struct bio *bio, int mirror_num)
BUG_ON(state->end != end);
spin_unlock_irq(&tree->lock);
- bio->bi_private = state;
+ bio->bi_private = NULL;
bio_get(bio);
--
1.5.5.1
--
David Woodhouse Open Source Technology Centre
David.Woodhouse@intel.com Intel Corporation
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Add compability for kernels >=2.6.27-rc1
2008-08-19 14:51 ` David Woodhouse
@ 2008-08-19 16:30 ` Chris Mason
0 siblings, 0 replies; 10+ messages in thread
From: Chris Mason @ 2008-08-19 16:30 UTC (permalink / raw)
To: David Woodhouse; +Cc: Jens Axboe, Sven Wegener, linux-btrfs
On Tue, Aug 19, 2008 at 03:51:40PM +0100, David Woodhouse wrote:
> On Thu, 2008-07-31 at 15:37 -0400, Chris Mason wrote:
> > > BUG: unable to handle kernel paging request at ffff880107c2aa00
> > > IP: [<ffffffffa03e73bc>] end_bio_extent_writepage+0x1f4/0x29c
> > [btrfs]
> >
> > If you can reliably reproduce this, please try with the spin locks
> > instead of rcu read locks. What were you doing at the time?
>
> Just using CONFIG_DEBUG_PAGEALLOC and dirtying a bunch of pages from
> different inodes seems enough. Another patch to add to my collection at
> git.infradead.org/users/dwmw2/btrfs-kernel-unstable.git ...
Great, I'm testing this locally, it should solve Toei Rei's oopsen. It
doesn't solve the missing checksum errors that Steve was hitting, but
I'm able to trigger those locally now and hope to nail them down
today.
-chris
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-08-19 16:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-30 19:11 [PATCH] Add compability for kernels >=2.6.27-rc1 Sven Wegener
2008-07-30 19:56 ` Jens Axboe
2008-07-30 20:11 ` Chris Mason
2008-07-30 20:13 ` Jens Axboe
2008-07-30 20:43 ` Chris Mason
2008-07-31 19:27 ` David Woodhouse
2008-07-31 19:37 ` Chris Mason
2008-07-31 19:52 ` David Woodhouse
2008-08-19 14:51 ` David Woodhouse
2008-08-19 16:30 ` Chris Mason
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox