+ generic_file_buffered_write-handle-zero-length-iovec-segments-stable.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     generic_file_buffered_write(): handle zero-length iovec segments

has been added to the -mm tree.  Its filename is

     generic_file_buffered_write-handle-zero-length-iovec-segments-stable.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: generic_file_buffered_write(): handle zero-length iovec segments
From: Andrew Morton <akpm@xxxxxxxx>

The recent generic_file_write() deadlock fix caused
generic_file_buffered_write() to loop inifinitely when presented with a
zero-length iovec segment.  Fix.

Note that this fix deliberately avoids calling ->prepare_write(),
->commit_write() etc with a zero-length write.  This is because I don't trust
all filesystems to get that right.

This is a cautious approach, for 2.6.17.x.  For 2.6.18 we should just go ahead
and call ->prepare_write() and ->commit_write() with the zero length and fix
any broken filesystems.  So I'll make that change once this code is stabilised
and backported into 2.6.17.x.

The reason for preferring to call ->prepare_write() and ->commit_write() with
the zero-length segment: a zero-length segment _should_ be sufficiently
uncommon that this is the correct way of handling it.  We don't want to
optimise for poorly-written userspace at the expense of well-written
userspace.

Cc: "Vladimir V. Saveliev" <vs@xxxxxxxxxxx>
Cc: Neil Brown <neilb@xxxxxxx>
Cc: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>
Cc: Chris Wright <chrisw@xxxxxxxxxxxx>
Cc: Greg KH <greg@xxxxxxxxx>
Cc: <stable@xxxxxxxxxx>
Cc: walt <wa1ter@xxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 mm/filemap.c |    9 ++++++++-
 mm/filemap.h |    4 ++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff -puN mm/filemap.c~generic_file_buffered_write-handle-zero-length-iovec-segments-stable mm/filemap.c
--- a/mm/filemap.c~generic_file_buffered_write-handle-zero-length-iovec-segments-stable
+++ a/mm/filemap.c
@@ -2125,6 +2125,12 @@ generic_file_buffered_write(struct kiocb
 			break;
 		}
 
+		if (unlikely(bytes == 0)) {
+			status = 0;
+			copied = 0;
+			goto zero_length_segment;
+		}
+
 		status = a_ops->prepare_write(file, page, offset, offset+bytes);
 		if (unlikely(status)) {
 			loff_t isize = i_size_read(inode);
@@ -2154,7 +2160,8 @@ generic_file_buffered_write(struct kiocb
 			page_cache_release(page);
 			continue;
 		}
-		if (likely(copied > 0)) {
+zero_length_segment:
+		if (likely(copied >= 0)) {
 			if (!status)
 				status = copied;
 
diff -puN mm/filemap.h~generic_file_buffered_write-handle-zero-length-iovec-segments-stable mm/filemap.h
--- a/mm/filemap.h~generic_file_buffered_write-handle-zero-length-iovec-segments-stable
+++ a/mm/filemap.h
@@ -88,7 +88,7 @@ filemap_set_next_iovec(const struct iove
 	const struct iovec *iov = *iovp;
 	size_t base = *basep;
 
-	while (bytes) {
+	do {
 		int copy = min(bytes, iov->iov_len - base);
 
 		bytes -= copy;
@@ -97,7 +97,7 @@ filemap_set_next_iovec(const struct iove
 			iov++;
 			base = 0;
 		}
-	}
+	} while (bytes);
 	*iovp = iov;
 	*basep = base;
 }
_

Patches currently in -mm which might be from akpm@xxxxxxxx are

origin.patch
x86-do_irq-check-irq-number.patch
load_module-cleanup.patch
x86_64-oprofile-build-fix.patch
vsnprintf-fix.patch
generic_file_buffered_write-handle-zero-length-iovec-segments-stable.patch
disable-debugging-version-of-write_lock.patch
git-acpi.patch
git-acpi-fixup.patch
acpi_srat-needs-acpi.patch
acpi-asus-s3-resume-fix-fix.patch
sony_apci-resume.patch
git-agpgart.patch
kauditd_thread-warning-fix.patch
i2c-801-64bit-resource-fix.patch
git-geode-fixup.patch
git-gfs2.patch
git-gfs2-fixup.patch
gfs2-get_sb_dev-fix.patch
revert-ignore-makes-built-in-rules-variables.patch
revert-sparc-build-breakage.patch
git-klibc.patch
git-klibc-fixup.patch
git-hdrcleanup-vs-git-klibc-on-ia64.patch
git-hdrcleanup-vs-git-klibc-on-ia64-2.patch
git-libata-all.patch
sata-is-bust-on-s390.patch
forcedeth-typecast-cleanup.patch
drivers-net-ns83820c-add-paramter-to-disable-auto.patch
af_unix-datagram-getpeersec-fix.patch
git-pcmcia-fixup.patch
powerpc-kcofnig-warning-fix.patch
git-sas.patch
git-sas-sas_discover-build-fix.patch
serial-8250-sysrq-deadlock-fix.patch
serial-fix-uart_bug_txen-test.patch
revert-gregkh-pci-pci-test-that-drivers-properly-call-pci_set_master.patch
clear-abnormal-poweroff-flag-on-via-southbridges-fix-resume-fix.patch
git-scsi-misc.patch
git-scsi-misc-fixup.patch
areca-raid-linux-scsi-driver.patch
git-scsi-target-fixup.patch
pm-usb-hcds-use-pm_event_prethaw-fix.patch
git-supertrak-fixup.patch
bcm43xx-opencoded-locking-fix.patch
adix-tree-rcu-lockless-readside-update-tidy.patch
zoned-vm-counters-create-vmstatc-h-from-page_allocc-h-s390-fix.patch
zoned-vm-counters-create-vmstatc-h-from-page_allocc-h-fix.patch
zoned-vm-counters-basic-zvc-zoned-vm-counter-implementation-tidy.patch
zoned-vm-counters-basic-zvc-zoned-vm-counter-implementation-export-vm_stat.patch
zoned-vm-counters-convert-nr_mapped-to-per-zone-counter-fix.patch
zoned-vm-counters-remove-nr_file_mapped-from-scan-control-structure-fix.patch
zoned-vm-counters-conversion-of-nr_slab-to-per-zone-counter-fix.patch
zoned-vm-counters-conversion-of-nr_pagetables-to-per-zone-counter-fix.patch
zoned-vm-counters-conversion-of-nr_dirty-to-per-zone-counter-fix.patch
zoned-vm-counters-conversion-of-nr_writeback-to-per-zone-counter.patch
zoned-vm-counters-conversion-of-nr_writeback-to-per-zone-counter-fix.patch
zoned-vm-counters-conversion-of-nr_unstable-to-per-zone-counter-nfs-fix.patch
zoned-vm-counters-conversion-of-nr_unstable-to-per-zone-counter-fix.patch
zoned-vm-counters-conversion-of-nr_bounce-to-per-zone-counter.patch
zoned-vm-counters-conversion-of-nr_bounce-to-per-zone-counter-fix.patch
zoned-vm-counters-remove-read_page_state.patch
mm-tracking-shared-dirty-pages-checks.patch
mm-tracking-shared-dirty-pages-wimp.patch
slab-consolidate-code-to-free-slabs-from-freelist-fix.patch
acx1xx-wireless-driver.patch
tiacx-pci-build-fix.patch
tiacx-ia64-fix.patch
add-smp_setup_processor_id.patch
deprecate-smbfs-in-favour-of-cifs.patch
destroy-the-dentries-contributed-by-a-superblock-on-unmounting-fix.patch
cond_resched-fix.patch
reiserfs-on-demand-bitmap-loading-fix.patch
per-task-delay-accounting-proc-export-of-aggregated-block-i-o-delays-warning-fix.patch
delay-accounting-taskstats-interface-send-tgid-once-fixes.patch
sched-clean-up-fallout-of-recent-changes-fix.patch
swap_prefetch-vs-zoned-counters.patch
mark-address_space_operations-const-vs-ecryptfs-mmap-operations.patch
ecryptfs-alpha-build-fix.patch
ecryptfs-more-elegant-aes-key-size-manipulation-tidy.patch
ecryptfs-get_sb_dev-fix.patch
namespaces-add-nsproxy-dont-include-compileh.patch
namespaces-utsname-switch-to-using-uts-namespaces-alpha-fix.patch
namespaces-utsname-use-init_utsname-when-appropriate-cifs-update.patch
namespaces-utsname-implement-utsname-namespaces-export.patch
namespaces-utsname-implement-utsname-namespaces-dont-include-compileh.patch
namespaces-utsname-sysctl-hack-cleanup-2-fix.patch
ipc-namespace-core-fix.patch
task-watchers-task-watchers-tidy.patch
task-watchers-add-support-for-per-task-watchers-warning-fix.patch
readahead-sysctl-parameters-fix.patch
make-copy_from_user_inatomic-not-zero-the-tail-on-i386-vs-reiser4.patch
reiser4-hardirq-include-fix.patch
reiser4-run-truncate_inode_pages-in-reiser4_delete_inode.patch
reiser4-get_sb_dev-fix.patch
reiser4-vs-zoned-allocator.patch
hpt3xx-rework-rate-filtering-tidy.patch
genirq-rename-desc-handler-to-desc-chip-power-fix.patch
genirq-rename-desc-handler-to-desc-chip-ia64-fix.patch
genirq-rename-desc-handler-to-desc-chip-ia64-fix-2.patch
genirq-rename-desc-handler-to-desc-chip-terminate_irqs-fix.patch
genirq-ia64-build-fix.patch
lockdep-add-disable-enable_irq_lockdep-api-fix.patch
lockdep-irqtrace-subsystem-x86_64-support-fix.patch
srcu-rcu-variant-permitting-read-side-blocking-fixes.patch
srcu-add-srcu-operations-to-rcutorture-fix.patch
srcu-2-add-srcu-operations-to-rcutorture-fix.patch
ro-bind-mounts-elevate-write-count-during-entire-ncp_ioctl-tidy.patch
nr_blockdev_pages-in_interrupt-warning.patch
device-suspend-debug.patch
revert-tty-buffering-comment-out-debug-code.patch
slab-leaks3-default-y.patch
x86-kmap_atomic-debugging.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux