From: Josef Bacik <jbacik@redhat.com> Date: Tue, 10 Feb 2009 13:49:16 -0500 Subject: [mm] kill the zero-length iovec segments handling Message-id: 1234291777-15344-4-git-send-email-jbacik@redhat.com O-Subject: [PATCH 03/24] [RHEL 5.4] kill the zero-length iovec segments handling Bugzilla: 445433 RH-Acked-by: Jeff Layton <jlayton@redhat.com> This patch is a backport of 4b49643fbb3fa8bf4910f82be02d45e94e8972a4 and is in reference to bz 445433. This is a revert of 81b0c8713385ce1b1b9058e916edcf9561ad76d6. This is needed in order to properly apply some of the following patches. Signed-off-by: Josef Bacik <jbacik@redhat.com> diff --git a/mm/filemap.c b/mm/filemap.c index d413c95..5b88813 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2188,12 +2188,6 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, 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); @@ -2223,8 +2217,7 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, page_cache_release(page); continue; } -zero_length_segment: - if (likely(copied >= 0)) { + if (likely(copied > 0)) { if (!status) status = copied; diff --git a/mm/filemap.h b/mm/filemap.h index c2bff04..a1e10a2 100644 --- a/mm/filemap.h +++ b/mm/filemap.h @@ -87,7 +87,7 @@ filemap_set_next_iovec(const struct iovec **iovp, size_t *basep, size_t bytes) const struct iovec *iov = *iovp; size_t base = *basep; - do { + while (bytes) { int copy = min(bytes, iov->iov_len - base); bytes -= copy; @@ -96,7 +96,7 @@ filemap_set_next_iovec(const struct iovec **iovp, size_t *basep, size_t bytes) iov++; base = 0; } - } while (bytes); + } *iovp = iov; *basep = base; }