platform/upstream/kernel-adaptation-pc.git
15 years agolguest: use eventfds for device notification
Rusty Russell [Sat, 13 Jun 2009 04:27:09 +0000 (22:27 -0600)]
lguest: use eventfds for device notification

Currently, when a Guest wants to perform I/O it calls LHCALL_NOTIFY with
an address: the main Launcher process returns with this address, and figures
out what device to run.

A far nicer model is to let processes bind an eventfd to an address: if we
find one, we simply signal the eventfd.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Davide Libenzi <davidel@xmailserver.org>
15 years agoeventfd: export eventfd_signal and eventfd_fget for lguest
Rusty Russell [Sat, 13 Jun 2009 04:27:09 +0000 (22:27 -0600)]
eventfd: export eventfd_signal and eventfd_fget for lguest

lguest wants to attach eventfds to guest notifications, and lguest is
usually a module.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
To: Davide Libenzi <davidel@xmailserver.org>

15 years agolguest: allow any process to send interrupts
Rusty Russell [Sat, 13 Jun 2009 04:27:08 +0000 (22:27 -0600)]
lguest: allow any process to send interrupts

We currently only allow the Launcher process to send interrupts, but it
as we already send interrupts from the hrtimer, it's a simple matter of
extracting that code into a common set_interrupt routine.

As we switch to a thread per virtqueue, this avoids a bottleneck through the
main Launcher process.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: PAE fixes
Rusty Russell [Sat, 13 Jun 2009 04:27:08 +0000 (22:27 -0600)]
lguest: PAE fixes

1) j wasn't initialized in setup_pagetables, so they weren't set up for me
   causing immediate guest crashes.

2) gpte_addr should not re-read the pmd from the Guest.  Especially
   not BUG_ON() based on the value.  If we ever supported SMP guests,
   they could trigger that.  And the Launcher could also trigger it
   (tho currently root-only).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: PAE support
Matias Zabaljauregui [Sat, 13 Jun 2009 04:27:07 +0000 (22:27 -0600)]
lguest: PAE support

This version requires that host and guest have the same PAE status.
NX cap is not offered to the guest, yet.

Signed-off-by: Matias Zabaljauregui <zabaljauregui@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: Add support for kvm_hypercall4()
Matias Zabaljauregui [Sat, 13 Jun 2009 04:27:07 +0000 (22:27 -0600)]
lguest: Add support for kvm_hypercall4()

Add support for kvm_hypercall4(); PAE wants it.

Signed-off-by: Matias Zabaljauregui <zabaljauregui at gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: replace hypercall name LHCALL_SET_PMD with LHCALL_SET_PGD
Matias Zabaljauregui [Sat, 30 May 2009 18:48:08 +0000 (15:48 -0300)]
lguest: replace hypercall name LHCALL_SET_PMD with LHCALL_SET_PGD

replace LHCALL_SET_PMD with LHCALL_SET_PGD hypercall name
(That's really what it is, and the confusion gets worse with PAE support)

Signed-off-by: Matias Zabaljauregui <zabaljauregui@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Reported-by: Jeremy Fitzhardinge <jeremy@goop.org>
15 years agolguest: use native_set_* macros, which properly handle 64-bit entries when PAE is...
Matias Zabaljauregui [Sat, 13 Jun 2009 04:27:06 +0000 (22:27 -0600)]
lguest: use native_set_* macros, which properly handle 64-bit entries when PAE is activated

Some cleanups and replace direct assignment with native_set_* macros which properly handle 64-bit entries when PAE is activated

Signed-off-by: Matias Zabaljauregui <zabaljauregui@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: map switcher with executable page table entries
Matias Zabaljauregui [Sat, 30 May 2009 18:35:49 +0000 (15:35 -0300)]
lguest: map switcher with executable page table entries

Map switcher with executable page table entries.
(This bug didn't matter before PAE and hence NX support -- RR)

Signed-off-by: Matias Zabaljauregui <zabaljauregui@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: fix writev returning short on console output
Rusty Russell [Sat, 13 Jun 2009 04:27:05 +0000 (22:27 -0600)]
lguest: fix writev returning short on console output

I've never seen it here, but I can't find anywhere that says writev
will write everything.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: clean up length-used value in example launcher
Rusty Russell [Sat, 13 Jun 2009 04:27:04 +0000 (22:27 -0600)]
lguest: clean up length-used value in example launcher

The "len" field in the used ring for virtio indicates the number of
bytes *written* to the buffer.  This means the guest doesn't have to
zero the buffers in advance as it always knows the used length.

Erroneously, the console and network example code puts the length
*read* into that field.  The guest ignores it, but it's wrong.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: Segment selectors are 16-bit long. Fix lg_cpu.ss1 definition.
Matias Zabaljauregui [Sat, 13 Jun 2009 04:27:04 +0000 (22:27 -0600)]
lguest: Segment selectors are 16-bit long. Fix lg_cpu.ss1 definition.

If GDT_ENTRIES were every > 256, this could become a problem.

Signed-off-by: Matias Zabaljauregui <zabaljauregui at gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: beyond ARRAY_SIZE of cpu->arch.gdt
Roel Kluin [Tue, 19 May 2009 23:45:45 +0000 (01:45 +0200)]
lguest: beyond ARRAY_SIZE of cpu->arch.gdt

Do not go beyond ARRAY_SIZE of cpu->arch.gdt

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: clean up example launcher compile flags.
Rusty Russell [Sat, 13 Jun 2009 04:27:03 +0000 (22:27 -0600)]
lguest: clean up example launcher compile flags.

18 months ago 5bbf89fc260830f3f58b331d946a16b39ad1ca2d changed to loading
bzImages directly, and no longer manually ungzipping them, so we no longer
need libz.

Also, -m32 is useful for those on 64-bit platforms (and harmless on
32-bit).

Reported-by: Ron Minnich <rminnich@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: optimize by coding restore_flags and irq_enable in assembler.
Rusty Russell [Sat, 13 Jun 2009 04:27:03 +0000 (22:27 -0600)]
lguest: optimize by coding restore_flags and irq_enable in assembler.

The downside of the last patch which made restore_flags and irq_enable
check interrupts is that they are now too big to be patched directly
into the callsites, so the C versions are always used.

But the C versions go via PV_CALLEE_SAVE_REGS_THUNK which saves all
the registers.  In fact, we don't need any registers in the fast path,
so we can do better than this if we actually code them in assembler.

The results are in the noise, but since it's about the same amount of
code, it's worth applying.

1GB Guest->Host: input(suppressed),output(suppressed)
Before:
Seconds: 0:16.53
Packets: 377268,753673
Interrupts: 22461,24297
Notifications: 1(5245),21303(732370)
Net IRQs triggered: 377023(245),42578(711095)

After:
Seconds: 0:16.48
Packets: 377289,753673
Interrupts: 22281,24465
Notifications: 1(5245),21296(732377)
Net IRQs triggered: 377060(229),42564(711109)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: improve interrupt handling, speed up stream networking
Rusty Russell [Sat, 13 Jun 2009 04:27:02 +0000 (22:27 -0600)]
lguest: improve interrupt handling, speed up stream networking

lguest never checked for pending interrupts when enabling interrupts, and
things still worked.  However, it makes a significant difference to TCP
performance, so it's time we fixed it by introducing a pending_irq flag
and checking it on irq_restore and irq_enable.

These two routines are now too big to patch into the 8/10 bytes
patch space, so we drop that code.

Note: The high latency on interrupt delivery had a very curious
effect: once everything else was optimized, networking without GSO was
faster than networking with GSO, since more interrupts were sent and
hence a greater chance of one getting through to the Guest!

Note2: (Almost) Closing the same loophole for iret doesn't have any
measurable effect, so I'm leaving that patch for the moment.

Before:
1GB tcpblast Guest->Host: 30.7 seconds
1GB tcpblast Guest->Host (no GSO): 76.0 seconds

After:
1GB tcpblast Guest->Host: 6.8 seconds
1GB tcpblast Guest->Host (no GSO): 27.8 seconds

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: fix race in halt code
Rusty Russell [Sat, 13 Jun 2009 04:27:02 +0000 (22:27 -0600)]
lguest: fix race in halt code

When the Guest does the LHCALL_HALT hypercall, we go to sleep, expecting
that a timer or the Waker will wake_up_process() us.

But we do it in a stupid way, leaving a classic missing wakeup race.

So split maybe_do_interrupt() into interrupt_pending() and
try_deliver_interrupt(), and check maybe_do_interrupt() and the
"break_out" flag before calling schedule.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: remove invalid interrupt forcing logic.
Rusty Russell [Sat, 13 Jun 2009 04:27:01 +0000 (22:27 -0600)]
lguest: remove invalid interrupt forcing logic.

20887611523e749d99cc7d64ff6c97d27529fbae (lguest: notify on empty) introduced
lguest support for the VIRTIO_F_NOTIFY_ON_EMPTY flag, but in fact it turned on
interrupts all the time.

Because we always process one buffer at a time, the inflight count is always 0
when call trigger_irq and so we always ignore VRING_AVAIL_F_NO_INTERRUPT from
the Guest.

It should be looking to see if there are more buffers in the Guest's queue:
if it's empty, then we force an interrupt.

This makes little difference, since we usually have an empty queue; but
that's the subject of another patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: fix lguest wake on guest clock tick, or fd activity
Rusty Russell [Sat, 13 Jun 2009 04:27:01 +0000 (22:27 -0600)]
lguest: fix lguest wake on guest clock tick, or fd activity

The Launcher could be inside the Guest on another CPU; wake_up_process
will do nothing because it is "running".  kick_process will knock it
back into our kernel in this case, otherwise we'll miss it until the
next guest exit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agosched: export kick_process
Rusty Russell [Sat, 13 Jun 2009 04:27:00 +0000 (22:27 -0600)]
sched: export kick_process

lguest needs kick_process: wake_up_process() does nothing if a process
is running, which isn't sufficient (we need it in the kernel).

And lguest support is usually modular.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Ingo Molnar <mingo@elte.hu>
15 years agolguest: get more serious about wmb() in example Launcher code
Rusty Russell [Sat, 13 Jun 2009 04:27:00 +0000 (22:27 -0600)]
lguest: get more serious about wmb() in example Launcher code

Since the Launcher process runs the Guest, it doesn't have to be very
serious about its barriers: the Guest isn't running while we are (Guest
is UP).

Before we change to use threads to service devices, we need to fix this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: clean up lguest_init_IRQ
Rusty Russell [Sat, 13 Jun 2009 04:26:59 +0000 (22:26 -0600)]
lguest: clean up lguest_init_IRQ

Copy from arch/x86/kernel/irqinit_32.c: we don't use the vectors beyond
LGUEST_IRQS (if any), but we might as well set them all.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: cleanup passing of /dev/lguest fd around example launcher.
Rusty Russell [Sat, 13 Jun 2009 04:26:59 +0000 (22:26 -0600)]
lguest: cleanup passing of /dev/lguest fd around example launcher.

We hand the /dev/lguest fd everywhere; it's far neater to just make it
a global (it already is, in fact, hidden in the waker_fds struct).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agolguest: be paranoid about guest playing with device descriptors.
Rusty Russell [Sat, 13 Jun 2009 04:26:58 +0000 (22:26 -0600)]
lguest: be paranoid about guest playing with device descriptors.

We can't trust the values in the device descriptor table once the
guest has booted, so keep local copies.  They could set them to
strange values then cause us to segv (they're 8 bit values, so they
can't make our pointers go too wild).

This becomes more important with the following patches which read them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
15 years agoblock: fix kernel-doc in recent block/ changes
Randy Dunlap [Fri, 12 Jun 2009 03:00:41 +0000 (20:00 -0700)]
block: fix kernel-doc in recent block/ changes

Fix kernel-doc warnings in recently changed block/ source code.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agoMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
Linus Torvalds [Fri, 12 Jun 2009 03:05:37 +0000 (20:05 -0700)]
Merge branch 'for-linus' of git://git./linux/kernel/git/viro/vfs-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (87 commits)
  nilfs2: get rid of bd_mount_sem use from nilfs
  nilfs2: correct exclusion control in nilfs_remount function
  nilfs2: simplify remaining sget() use
  nilfs2: get rid of sget use for checking if current mount is present
  nilfs2: get rid of sget use for acquiring nilfs object
  nilfs2: remove meaningless EBUSY case from nilfs_get_sb function
  remove the call to ->write_super in __sync_filesystem
  nilfs2: call nilfs2_write_super from nilfs2_sync_fs
  jffs2: call jffs2_write_super from jffs2_sync_fs
  ufs: add ->sync_fs
  sysv: add ->sync_fs
  hfsplus: add ->sync_fs
  hfs: add ->sync_fs
  fat: add ->sync_fs
  ext2: add ->sync_fs
  exofs: add ->sync_fs
  bfs: add ->sync_fs
  affs: add ->sync_fs
  sanitize ->fsync() for affs
  repair bfs_write_inode(), switch bfs to simple_fsync()
  ...

15 years agoMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu
Linus Torvalds [Fri, 12 Jun 2009 03:05:08 +0000 (20:05 -0700)]
Merge branch 'for-linus' of git://git./linux/kernel/git/gerg/m68knommu

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu:
  m68knommu: remove unecessary include of thread_info.h in entry.S
  m68knommu: enumerate INIT_THREAD fields properly
  headers_check fix: m68k, swab.h
  arch/m68knommu: Convert #ifdef DEBUG printk(KERN_DEBUG to pr_debug(
  m68knommu: remove obsolete reset code
  m68knommu: move CPU reset code for the 5272 ColdFire into its platform code
  m68knommu: move CPU reset code for the 528x ColdFire into its platform code
  m68knommu: move CPU reset code for the 527x ColdFire into its platform code
  m68knommu: move CPU reset code for the 523x ColdFire into its platform code
  m68knommu: move CPU reset code for the 520x ColdFire into its platform code
  m68knommu: add CPU reset code for the 532x ColdFire
  m68knommu: add CPU reset code for the 5249 ColdFire
  m68knommu: add CPU reset code for the 5206e ColdFire
  m68knommu: add CPU reset code for the 5206 ColdFire
  m68knommu: add CPU reset code for the 5407 ColdFire
  m68knommu: add CPU reset code for the 5307 ColdFire
  m68knommu: merge system reset for code ColdFire 523x family
  m68knommu: fix system reset for ColdFire 527x family

15 years agokvm: remove the duplicated cpumask_clear
Yinghai Lu [Thu, 11 Jun 2009 22:09:00 +0000 (15:09 -0700)]
kvm: remove the duplicated cpumask_clear

zalloc_cpumask_var already cleared it.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agox86: use zalloc_cpumask_var in arch_early_irq_init
Yinghai Lu [Thu, 11 Jun 2009 22:07:48 +0000 (15:07 -0700)]
x86: use zalloc_cpumask_var in arch_early_irq_init

So we make sure MAXSMP gets a cleared cpumask

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agoperfcounters: remove powerpc definitions of perf_counter_do_pending
Stephen Rothwell [Fri, 12 Jun 2009 00:14:22 +0000 (10:14 +1000)]
perfcounters: remove powerpc definitions of perf_counter_do_pending

Commit 925d519ab82b6dd7aca9420d809ee83819c08db2 ("perf_counter:
unify and fix delayed counter wakeup") added global definitions.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: Paul Mackerras <paulus@samba.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agonilfs2: get rid of bd_mount_sem use from nilfs
Ryusuke Konishi [Sun, 7 Jun 2009 16:39:33 +0000 (01:39 +0900)]
nilfs2: get rid of bd_mount_sem use from nilfs

This will remove every bd_mount_sem use in nilfs.

The intended exclusion control was replaced by the previous patch
("nilfs2: correct exclusion control in nilfs_remount function") for
nilfs_remount(), and this patch will replace remains with a new mutex
that this inserts in nilfs object.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agonilfs2: correct exclusion control in nilfs_remount function
Ryusuke Konishi [Sun, 7 Jun 2009 16:39:32 +0000 (01:39 +0900)]
nilfs2: correct exclusion control in nilfs_remount function

nilfs_remount() changes mount state of a superblock instance.  Even
though nilfs accesses other superblock instances during mount or
remount, the mount state was not properly protected in
nilfs_remount().

Moreover, nilfs_remount() has a lock order reversal problem;
nilfs_get_sb() holds:

  1. bdev->bd_mount_sem
  2. sb->s_umount  (sget acquires)

and nilfs_remount() holds:

  1. sb->s_umount  (locked by the caller in vfs)
  2. bdev->bd_mount_sem

To avoid these problems, this patch divides a semaphore protecting
super block instances from nilfs->ns_sem, and applies it to the mount
state protection in nilfs_remount().

With this change, bd_mount_sem use is removed from nilfs_remount() and
the lock order reversal will be resolved.  And the new rw-semaphore,
nilfs->ns_super_sem will properly protect the mount state except the
modification from nilfs_error function.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agonilfs2: simplify remaining sget() use
Ryusuke Konishi [Sun, 7 Jun 2009 16:39:31 +0000 (01:39 +0900)]
nilfs2: simplify remaining sget() use

This simplifies the test function passed on the remaining sget()
callsite in nilfs.

Instead of checking mount type (i.e. ro-mount/rw-mount/snapshot mount)
in the test function passed to sget(), this patch first looks up the
nilfs_sb_info struct which the given mount type matches, and then
acquires the super block instance holding the nilfs_sb_info.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agonilfs2: get rid of sget use for checking if current mount is present
Ryusuke Konishi [Sun, 7 Jun 2009 16:39:30 +0000 (01:39 +0900)]
nilfs2: get rid of sget use for checking if current mount is present

This stops using sget() for checking if an r/w-mount or an r/o-mount
exists on the device.  This elimination uses a back pointer to the
current mount added to nilfs object.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agonilfs2: get rid of sget use for acquiring nilfs object
Ryusuke Konishi [Sun, 7 Jun 2009 16:39:29 +0000 (01:39 +0900)]
nilfs2: get rid of sget use for acquiring nilfs object

This will change the way to obtain nilfs object in nilfs_get_sb()
function.

Previously, a preliminary sget() call was performed, and the nilfs
object was acquired from a super block instance found by the sget()
call.

This patch, instead, instroduces a new dedicated function
find_or_create_nilfs(); as the name implies, the function finds an
existent nilfs object from a global list or creates a new one if no
object is found on the device.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agonilfs2: remove meaningless EBUSY case from nilfs_get_sb function
Ryusuke Konishi [Sun, 7 Jun 2009 16:39:28 +0000 (01:39 +0900)]
nilfs2: remove meaningless EBUSY case from nilfs_get_sb function

The following EBUSY case in nilfs_get_sb() is meaningless.  Indeed,
this error code is never returned to the caller.

    if (!s->s_root) {
          ...
    } else if (!(s->s_flags & MS_RDONLY)) {
        err = -EBUSY;
    }

This simply removes the else case.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoremove the call to ->write_super in __sync_filesystem
Christoph Hellwig [Mon, 8 Jun 2009 08:08:54 +0000 (10:08 +0200)]
remove the call to ->write_super in __sync_filesystem

Now that all filesystems provide ->sync_fs methods we can change
__sync_filesystem to only call ->sync_fs.

This gives us a clear separation between periodic writeouts which
are driven by ->write_super and data integrity syncs that go
through ->sync_fs. (modulo file_fsync which is also going away)

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agonilfs2: call nilfs2_write_super from nilfs2_sync_fs
Christoph Hellwig [Mon, 8 Jun 2009 08:08:36 +0000 (10:08 +0200)]
nilfs2: call nilfs2_write_super from nilfs2_sync_fs

The call to ->write_super from __sync_filesystem will go away, so make
sure nilfs2 performs the same actions from inside ->sync_fs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agojffs2: call jffs2_write_super from jffs2_sync_fs
Christoph Hellwig [Mon, 8 Jun 2009 08:08:21 +0000 (10:08 +0200)]
jffs2: call jffs2_write_super from jffs2_sync_fs

The call to ->write_super from __sync_filesystem will go away, so make
sure jffs2 performs the same actions from inside ->sync_fs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoufs: add ->sync_fs
Christoph Hellwig [Mon, 8 Jun 2009 08:08:05 +0000 (10:08 +0200)]
ufs: add ->sync_fs

Add a ->sync_fs method for data integrity syncs, and reimplement
->write_super ontop of it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agosysv: add ->sync_fs
Christoph Hellwig [Mon, 8 Jun 2009 08:07:45 +0000 (10:07 +0200)]
sysv: add ->sync_fs

Add a ->sync_fs method for data integrity syncs, and reimplement
->write_super ontop of it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agohfsplus: add ->sync_fs
Christoph Hellwig [Mon, 8 Jun 2009 08:05:12 +0000 (10:05 +0200)]
hfsplus: add ->sync_fs

Add a ->sync_fs method for data integrity syncs, and reimplement
->write_super ontop of it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agohfs: add ->sync_fs
Christoph Hellwig [Mon, 8 Jun 2009 08:04:54 +0000 (10:04 +0200)]
hfs: add ->sync_fs

Add a ->sync_fs method for data integrity syncs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agofat: add ->sync_fs
Christoph Hellwig [Mon, 8 Jun 2009 08:04:35 +0000 (10:04 +0200)]
fat: add ->sync_fs

Add a ->sync_fs method for data integrity syncs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoext2: add ->sync_fs
Christoph Hellwig [Mon, 8 Jun 2009 08:04:17 +0000 (10:04 +0200)]
ext2: add ->sync_fs

Add a ->sync_fs method for data integrity syncs, and reimplement
->write_super ontop of it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoexofs: add ->sync_fs
Christoph Hellwig [Mon, 8 Jun 2009 08:03:58 +0000 (10:03 +0200)]
exofs: add ->sync_fs

Add a ->sync_fs method for data integrity syncs, and reimplement
->write_super ontop of it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agobfs: add ->sync_fs
Christoph Hellwig [Mon, 8 Jun 2009 08:03:38 +0000 (10:03 +0200)]
bfs: add ->sync_fs

Add a ->sync_fs method for data integrity syncs, and reimplement
->write_super ontop of it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoaffs: add ->sync_fs
Christoph Hellwig [Mon, 8 Jun 2009 08:03:15 +0000 (10:03 +0200)]
affs: add ->sync_fs

Add a ->sync_fs method for data integrity syncs.  Factor out common code
between affs_put_super, affs_write_super and the new affs_sync_fs into
a helper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agosanitize ->fsync() for affs
Al Viro [Mon, 8 Jun 2009 05:22:00 +0000 (01:22 -0400)]
sanitize ->fsync() for affs

unfortunately, for affs (especially for affs directories) we have
no real way to keep track of metadata ownership.  So we have to
do more or less what file_fsync() does, but we do *not* need to
call write_super() there.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agorepair bfs_write_inode(), switch bfs to simple_fsync()
Al Viro [Mon, 8 Jun 2009 05:15:58 +0000 (01:15 -0400)]
repair bfs_write_inode(), switch bfs to simple_fsync()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoFix adfs GET_FRAG_ID() on big-endian
Al Viro [Mon, 8 Jun 2009 04:46:40 +0000 (00:46 -0400)]
Fix adfs GET_FRAG_ID() on big-endian

Missing conversion to host-endian before doing shifts

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agorepair adfs ->write_inode(), switch to simple_fsync()
Al Viro [Mon, 8 Jun 2009 04:44:42 +0000 (00:44 -0400)]
repair adfs ->write_inode(), switch to simple_fsync()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoswitch omfs to simple_fsync()
Al Viro [Sun, 7 Jun 2009 19:44:50 +0000 (15:44 -0400)]
switch omfs to simple_fsync()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoswitch udf to simple_fsync()
Al Viro [Sun, 7 Jun 2009 19:40:27 +0000 (15:40 -0400)]
switch udf to simple_fsync()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoswitch ufs to simple_fsync()
Al Viro [Sun, 7 Jun 2009 19:35:18 +0000 (15:35 -0400)]
switch ufs to simple_fsync()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agorepair sysv_write_inode(), switch sysv to simple_fsync()
Al Viro [Sun, 7 Jun 2009 19:29:45 +0000 (15:29 -0400)]
repair sysv_write_inode(), switch sysv to simple_fsync()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoswitch minix to simple_fsync()
Al Viro [Sun, 7 Jun 2009 19:21:06 +0000 (15:21 -0400)]
switch minix to simple_fsync()

* get minix_write_inode() to honour the second argument
* now we can use simple_fsync() for minixfs

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoswitch ext2 to simple_fsync()
Al Viro [Sun, 7 Jun 2009 19:14:02 +0000 (15:14 -0400)]
switch ext2 to simple_fsync()

kill ext2_sync_file() (along with ext2/fsync.c), get rid of
ext2_update_inode() - it's an alias of ext2_write_inode().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoSanitize ->fsync() for FAT
Al Viro [Sun, 7 Jun 2009 17:44:36 +0000 (13:44 -0400)]
Sanitize ->fsync() for FAT

* mark directory data blocks as assoc. metadata
* add new inode to deal with FAT, mark FAT blocks as assoc. metadata of that
* now ->fsync() is trivial both for files and directories

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agofs/qnx4: sanitize includes
Al Viro [Sun, 7 Jun 2009 13:47:13 +0000 (09:47 -0400)]
fs/qnx4: sanitize includes

fs-internal parts of qnx4_fs.h taken to fs/qnx4/qnx4.h, includes adjusted,
qnx4_fs.h doesn't need unifdef anymore.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoSanitize qnx4 fsync handling
Al Viro [Sun, 7 Jun 2009 13:30:08 +0000 (09:30 -0400)]
Sanitize qnx4 fsync handling

* have directory operations use mark_buffer_dirty_inode(),
  so that sync_mapping_buffers() would get those.
* make qnx4_write_inode() honour its last argument.
* get rid of insane copies of very ancient "walk the indirect blocks"
  in qnx4/fsync - they never matched the actual fs layout and, fortunately,
  never'd been called.  Again, all this junk is not needed; ->fsync()
  should just do sync_mapping_buffers + sync_inode (and if we implement
  block allocation for qnx4, we'll need to use mark_buffer_dirty_inode()
  for extent blocks)

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoNew helper - simple_fsync()
Al Viro [Sun, 7 Jun 2009 18:56:44 +0000 (14:56 -0400)]
New helper - simple_fsync()

writes associated buffers, then does sync_inode() to write
the inode itself (and to make it clean).  Depends on
->write_inode() honouring the second argument.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoPush BKL down into ->remount_fs()
Alessio Igor Bogani [Tue, 12 May 2009 13:10:54 +0000 (15:10 +0200)]
Push BKL down into ->remount_fs()

[xfs, btrfs, capifs, shmem don't need BKL, exempt]

Signed-off-by: Alessio Igor Bogani <abogani@texware.it>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agofs: block_dump missing dentry locking
Nick Piggin [Thu, 28 May 2009 07:01:15 +0000 (09:01 +0200)]
fs: block_dump missing dentry locking

I think the block_dump output in __mark_inode_dirty is missing dentry locking.
Surely the i_dentry list can change any time, so we may not even *get* a
dentry there. If we do get one by chance, then it would appear to be able to
go away or get renamed at any time...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agofs: remove incorrect I_NEW warnings
Nick Piggin [Tue, 2 Jun 2009 10:07:47 +0000 (12:07 +0200)]
fs: remove incorrect I_NEW warnings

Some filesystems can call in to sync an inode that is still in the
I_NEW state (eg. ext family, when mounted with -osync). This is OK
because the filesystem has sole access to the new inode, so it can
modify i_state without races (because no other thread should be
modifying it, by definition of I_NEW). Ie. a false positive, so
remove the warnings.

The races are described here 7ef0d7377cb287e08f3ae94cebc919448e1f5dff,
which is also where the warnings were introduced.

Reported-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agolinux/magic.h: move cramfs magic out of cramfs_fs.h
Mike Frysinger [Tue, 26 May 2009 09:45:04 +0000 (05:45 -0400)]
linux/magic.h: move cramfs magic out of cramfs_fs.h

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoxfs: remove ->write_super and stop maintaining ->s_dirt
Christoph Hellwig [Fri, 5 Jun 2009 10:26:23 +0000 (12:26 +0200)]
xfs: remove ->write_super and stop maintaining ->s_dirt

the write_super method is used for

 (1) writing back the superblock periodically from pdflush
 (2) called just before ->sync_fs for data integerity syncs

We don't need (1) because we have our own peridoc writeout through xfssyncd,
and we don't need (2) because xfs_fs_sync_fs performs a proper synchronous
superblock writeout after all other data and metadata has been written out.

Also remove ->s_dirt tracking as it's only used to decide when too call
->write_super.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agontfs: remove old debug check for dirty data in ntfs_put_super()
Jens Axboe [Mon, 25 May 2009 07:30:45 +0000 (09:30 +0200)]
ntfs: remove old debug check for dirty data in ntfs_put_super()

This should not trigger anymore, so kill it.

Acked-by: Anton Altaparmakov <aia21@cam.ac.uk>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agofs: Rearrange inode structure elements to avoid waste due to padding
Theodore Ts'o [Thu, 21 May 2009 20:01:02 +0000 (16:01 -0400)]
fs: Rearrange inode structure elements to avoid waste due to padding

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agofs: Remove i_cindex from struct inode
Theodore Ts'o [Thu, 21 May 2009 20:01:00 +0000 (16:01 -0400)]
fs: Remove i_cindex from struct inode

The only user of the i_cindex element in the inode structure is used
is by the firewire drivers.  As part of an attempt to slim down the
inode structure to save memory --- since a typical Linux system will
have hundreds of thousands if not millions of inodes cached, a
reduction in the size inode has high leverage.

The firewire driver does not need i_cindex in any fast path, so it's
simple enough to calculate when it is needed, instead of wasting space
in the inode structure.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: krh@redhat.com
Cc: stefanr@s5r6.in-berlin.de
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years ago->write_super lock_super pushdown
Christoph Hellwig [Mon, 11 May 2009 21:35:03 +0000 (23:35 +0200)]
->write_super lock_super pushdown

Push down lock_super into ->write_super instances and remove it from the
caller.

Following filesystem don't need ->s_lock in ->write_super and are skipped:

 * bfs, nilfs2 - no other uses of s_lock and have internal locks in
->write_super
 * ext2 - uses BKL in ext2_write_super and has internal calls without s_lock
 * reiserfs - no other uses of s_lock as has reiserfs_write_lock (BKL) in
  ->write_super
 * xfs - no other uses of s_lock and uses internal lock (buffer lock on
superblock buffer) to serialize ->write_super.  Also xfs_fs_write_super
is superflous and will go away in the next merge window

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agojffs2: move jffs2_write_super to super.c
Christoph Hellwig [Mon, 11 May 2009 21:34:27 +0000 (23:34 +0200)]
jffs2: move jffs2_write_super to super.c

jffs2_write_super is only called from super.c and doesn't use any
functionality from fs.c.  So move it over to super.c and make it
static there.

[should go in through the vfs tree as it is a requirement for the
 next patch]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoPush BKL down into do_remount_sb()
Al Viro [Fri, 8 May 2009 17:36:58 +0000 (13:36 -0400)]
Push BKL down into do_remount_sb()

[folded fix from Jiri Slaby]

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoPush BKL down beyond VFS-only parts of do_mount()
Al Viro [Fri, 8 May 2009 17:34:06 +0000 (13:34 -0400)]
Push BKL down beyond VFS-only parts of do_mount()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoPush BKL into do_mount()
Al Viro [Fri, 8 May 2009 17:31:17 +0000 (13:31 -0400)]
Push BKL into do_mount()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoPush lock_super() into the ->remount_fs() of filesystems that care about it
Al Viro [Wed, 6 May 2009 14:43:07 +0000 (10:43 -0400)]
Push lock_super() into the ->remount_fs() of filesystems that care about it

Note that since we can't run into contention between remount_fs and write_super
(due to exclusion on s_umount), we have to care only about filesystems that
touch lock_super() on their own.  Out of those ext3, ext4, hpfs, sysv and ufs
do need it; fat doesn't since its ->remount_fs() only accesses assign-once
data (basically, it's "we have no atime on directories and only have atime on
files for vfat; force nodiratime and possibly noatime into *flags").

[folded a build fix from hch]

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agopush BKL down into ->put_super
Christoph Hellwig [Tue, 5 May 2009 13:40:36 +0000 (15:40 +0200)]
push BKL down into ->put_super

Move BKL into ->put_super from the only caller.  A couple of
filesystems had trivial enough ->put_super (only kfree and NULLing of
s_fs_info + stuff in there) to not get any locking: coda, cramfs, efs,
hugetlbfs, omfs, qnx4, shmem, all others got the full treatment.  Most
of them probably don't need it, but I'd rather sort that out individually.
Preferably after all the other BKL pushdowns in that area.

[AV: original used to move lock_super() down as well; these changes are
removed since we don't do lock_super() at all in generic_shutdown_super()
now]
[AV: fuse, btrfs and xfs are known to need no damn BKL, exempt]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoNo need to do lock_super() for exclusion in generic_shutdown_super()
Al Viro [Wed, 6 May 2009 02:10:44 +0000 (22:10 -0400)]
No need to do lock_super() for exclusion in generic_shutdown_super()

We can't run into contention on it.  All other callers of lock_super()
either hold s_umount (and we have it exclusive) or hold an active
reference to superblock in question, which prevents the call of
generic_shutdown_super() while the reference is held.  So we can
replace lock_super(s) with get_fs_excl() in generic_shutdown_super()
(and corresponding change for unlock_super(), of course).

Since ext4 expects s_lock held for its put_super, take lock_super()
into it.  The rest of filesystems do not care at all.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoTrim a bit of crap from fs.h
Al Viro [Thu, 7 May 2009 07:12:29 +0000 (03:12 -0400)]
Trim a bit of crap from fs.h

do_remount_sb() is fs/internal.h fodder, fsync_no_super() is long gone.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoMake sure that all callers of remount hold s_umount exclusive
Al Viro [Wed, 6 May 2009 03:48:50 +0000 (23:48 -0400)]
Make sure that all callers of remount hold s_umount exclusive

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoenforce ->sync_fs is only called for rw superblock
Christoph Hellwig [Tue, 5 May 2009 13:41:25 +0000 (15:41 +0200)]
enforce ->sync_fs is only called for rw superblock

Make sure a superblock really is writeable by checking MS_RDONLY
under s_umount.  sync_filesystems needed some re-arragement for
that, but all but one sync_filesystem caller had the correct locking
already so that we could add that check there.  cachefiles grew
s_umount locking.

I've also added a WARN_ON to sync_filesystem to assert this for
future callers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agocleanup sync_supers
Christoph Hellwig [Tue, 5 May 2009 14:08:56 +0000 (16:08 +0200)]
cleanup sync_supers

Merge the write_super helper into sync_super and move the check for
->write_super earlier so that we can avoid grabbing a reference to
a superblock that doesn't have it.

While we're at it also add a little comment documenting sync_supers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agodcache: extrace and use d_unlinked()
Alexey Dobriyan [Sun, 3 May 2009 23:32:03 +0000 (03:32 +0400)]
dcache: extrace and use d_unlinked()

d_unlinked() will be used in middle-term to ban checkpointing when opened
but unlinked file is detected, and in long term, to detect such situation
and special case on it.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoremove ->write_super call in generic_shutdown_super
Christoph Hellwig [Tue, 28 Apr 2009 16:00:26 +0000 (18:00 +0200)]
remove ->write_super call in generic_shutdown_super

We just did a full fs writeout using sync_filesystem before, and if
that's not enough for the filesystem it can perform it's own writeout
in ->put_super, which many filesystems already do.

Move a call to foofs_write_super into every foofs_put_super for now to
guarantee identical behaviour until it's cleaned up by the individual
filesystem maintainers.

Exceptions:

 - affs already has identical copy & pasted code at the beginning of
   affs_put_super so no need to do it twice.
 - xfs does the right thing without it and I have changes pending for
   the xfs tree touching this are so I don't really need conflicts
   here..

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoqnx4: remove ->write_super
Christoph Hellwig [Mon, 27 Apr 2009 13:46:45 +0000 (09:46 -0400)]
qnx4: remove ->write_super

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoocfs2: remove ->write_super and stop maintaining ->s_dirt
Christoph Hellwig [Mon, 27 Apr 2009 13:46:44 +0000 (09:46 -0400)]
ocfs2: remove ->write_super and stop maintaining ->s_dirt

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agogfs2: remove ->write_super and stop maintaining ->s_dirt
Christoph Hellwig [Mon, 27 Apr 2009 13:46:43 +0000 (09:46 -0400)]
gfs2: remove ->write_super and stop maintaining ->s_dirt

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Steven Whitehouse <swhiteho@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoext3: remove ->write_super and stop maintaining ->s_dirt
Christoph Hellwig [Mon, 27 Apr 2009 13:46:42 +0000 (09:46 -0400)]
ext3: remove ->write_super and stop maintaining ->s_dirt

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agobtrfs: remove ->write_super and stop maintaining ->s_dirt
Christoph Hellwig [Mon, 27 Apr 2009 13:46:41 +0000 (09:46 -0400)]
btrfs: remove ->write_super and stop maintaining ->s_dirt

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoquota: Introduce writeout_quota_sb() (version 4)
Jan Kara [Mon, 27 Apr 2009 14:43:55 +0000 (16:43 +0200)]
quota: Introduce writeout_quota_sb() (version 4)

Introduce this function which just writes all the quota structures but
avoids all the syncing and cache pruning work to expose quota structures
to userspace. Use this function from __sync_filesystem when wait == 0.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoquota: cleanup dquota sync functions (version 4)
Christoph Hellwig [Mon, 27 Apr 2009 14:43:54 +0000 (16:43 +0200)]
quota: cleanup dquota sync functions (version 4)

Currently the VFS calls vfs_dq_sync to sync out disk quotas for a given
superblock.  This is a small wrapper around sync_dquots which for the
case of a non-NULL superblock is a small wrapper around quota_sync_sb.

Just make quota_sync_sb global (rename it to sync_quota_sb) and call it
directly.  Also call it directly for those cases in quota.c that have a
superblock and leave sync_dquots purely an iterator over sync_quota_sb and
remove it's superblock argument.

To make this nicer move the check for the lack of a quota_sync method
from the callers into sync_quota_sb.

[folded build fix from Alexander Beregalov <a.beregalov@gmail.com>]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agovfs: Rename fsync_super() to sync_filesystem() (version 4)
Jan Kara [Mon, 27 Apr 2009 14:43:53 +0000 (16:43 +0200)]
vfs: Rename fsync_super() to sync_filesystem() (version 4)

Rename the function so that it better describe what it really does. Also
remove the unnecessary include of buffer_head.h.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agovfs: Move syncing code from super.c to sync.c (version 4)
Jan Kara [Mon, 27 Apr 2009 14:43:52 +0000 (16:43 +0200)]
vfs: Move syncing code from super.c to sync.c (version 4)

Move sync_filesystems(), __fsync_super(), fsync_super() from
super.c to sync.c where it fits better.

[build fixes folded]

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agovfs: Make sys_sync() use fsync_super() (version 4)
Jan Kara [Mon, 27 Apr 2009 14:43:51 +0000 (16:43 +0200)]
vfs: Make sys_sync() use fsync_super() (version 4)

It is unnecessarily fragile to have two places (fsync_super() and do_sync())
doing data integrity sync of the filesystem. Alter __fsync_super() to
accommodate needs of both callers and use it. So after this patch
__fsync_super() is the only place where we gather all the calls needed to
properly send all data on a filesystem to disk.

Nice bonus is that we get a complete livelock avoidance and write_supers()
is now only used for periodic writeback of superblocks.

sync_blockdevs() introduced a couple of patches ago is gone now.

[build fixes folded]

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agovfs: Make __fsync_super() a static function (version 4)
Jan Kara [Mon, 27 Apr 2009 14:43:50 +0000 (16:43 +0200)]
vfs: Make __fsync_super() a static function (version 4)

__fsync_super() does the same thing as fsync_super(). So change the only
caller to use fsync_super() and make __fsync_super() static. This removes
unnecessarily duplicated call to sync_blockdev() and prepares ground
for the changes to __fsync_super() in the following patches.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agovfs: Call ->sync_fs() even if s_dirt is 0 (version 4)
Jan Kara [Mon, 27 Apr 2009 14:43:49 +0000 (16:43 +0200)]
vfs: Call ->sync_fs() even if s_dirt is 0 (version 4)

sync_filesystems() has a condition that if wait == 0 and s_dirt == 0, then
->sync_fs() isn't called. This does not really make much sence since s_dirt is
generally used by a filesystem to mean that ->write_super() needs to be called.
But ->sync_fs() does different things. I even suspect that some filesystems
(btrfs?) sets s_dirt just to fool this logic.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agovfs: Fix sys_sync() and fsync_super() reliability (version 4)
Jan Kara [Mon, 27 Apr 2009 14:43:48 +0000 (16:43 +0200)]
vfs: Fix sys_sync() and fsync_super() reliability (version 4)

So far, do_sync() called:
  sync_inodes(0);
  sync_supers();
  sync_filesystems(0);
  sync_filesystems(1);
  sync_inodes(1);

This ordering makes it kind of hard for filesystems as sync_inodes(0) need not
submit all the IO (for example it skips inodes with I_SYNC set) so e.g. forcing
transaction to disk in ->sync_fs() is not really enough. Therefore sys_sync has
not been completely reliable on some filesystems (ext3, ext4, reiserfs, ocfs2
and others are hit by this) when racing e.g. with background writeback. A
similar problem hits also other filesystems (e.g. ext2) because of
write_supers() being called before the sync_inodes(1).

Change the ordering of calls in do_sync() - this requires a new function
sync_blockdevs() to preserve the property that block devices are always synced
after write_super() / sync_fs() call.

The same issue is fixed in __fsync_super() function used on umount /
remount read-only.

[AV: build fixes]

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agoremove s_async_list
Christoph Hellwig [Tue, 28 Apr 2009 16:05:55 +0000 (18:05 +0200)]
remove s_async_list

Remove the unused s_async_list in the superblock, a leftover of the
broken async inode deletion code that leaked into mainline.  Having this
in the middle of the sync/unmount path is not helpful for the following
cleanups.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agofs: move mark_files_ro into file_table.c
npiggin@suse.de [Sun, 26 Apr 2009 10:25:56 +0000 (20:25 +1000)]
fs: move mark_files_ro into file_table.c

This function walks the s_files lock, and operates primarily on the
files in a superblock, so it better belongs here (eg. see also
fs_may_remount_ro).

[AV: ... and it shouldn't be static after that move]

Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
15 years agofs: introduce mnt_clone_write
npiggin@suse.de [Sun, 26 Apr 2009 10:25:55 +0000 (20:25 +1000)]
fs: introduce mnt_clone_write

This patch speeds up lmbench lat_mmap test by about another 2% after the
first patch.

Before:
 avg = 462.286
 std = 5.46106

After:
 avg = 453.12
 std = 9.58257

(50 runs of each, stddev gives a reasonable confidence)

It does this by introducing mnt_clone_write, which avoids some heavyweight
operations of mnt_want_write if called on a vfsmount which we know already
has a write count; and mnt_want_write_file, which can call mnt_clone_write
if the file is open for write.

After these two patches, mnt_want_write and mnt_drop_write go from 7% on
the profile down to 1.3% (including mnt_clone_write).

[AV: mnt_want_write_file() should take file alone and derive mnt from it;
not only all callers have that form, but that's the only mnt about which
we know that it's already held for write if file is opened for write]

Cc: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>