Joel Becker 5693486bad ocfs2: Zero the tail cluster when extending past i_size.
ocfs2's allocation unit is the cluster.  This can be larger than a block
or even a memory page.  This means that a file may have many blocks in
its last extent that are beyond the block containing i_size.  There also
may be more unwritten extents after that.

When ocfs2 grows a file, it zeros the entire cluster in order to ensure
future i_size growth will see cleared blocks.  Unfortunately,
block_write_full_page() drops the pages past i_size.  This means that
ocfs2 is actually leaking garbage data into the tail end of that last
cluster.  This is a bug.

We adjust ocfs2_write_begin_nolock() and ocfs2_extend_file() to detect
when a write or truncate is past i_size.  They will use
ocfs2_zero_extend() to ensure the data is properly zeroed.

Older versions of ocfs2_zero_extend() simply zeroed every block between
i_size and the zeroing position.  This presumes three things:

1) There is allocation for all of these blocks.
2) The extents are not unwritten.
3) The extents are not refcounted.

(1) and (2) hold true for non-sparse filesystems, which used to be the
only users of ocfs2_zero_extend().  (3) is another bug.

Since we're now using ocfs2_zero_extend() for sparse filesystems as
well, we teach ocfs2_zero_extend() to check every extent between
i_size and the zeroing position.  If the extent is unwritten, it is
ignored.  If it is refcounted, it is CoWed.  Then it is zeroed.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Cc: stable@kernel.org
2010-07-08 13:25:35 -07:00
..
2010-05-27 22:05:02 -04:00
2010-05-27 09:12:41 -07:00
2010-06-01 17:15:52 +00:00
2010-05-19 22:41:57 -04:00
2010-04-30 14:52:51 -05:00
2009-06-17 00:36:36 -04:00
2010-06-04 17:16:30 -04:00
2010-05-27 09:12:47 -07:00
2010-01-26 22:22:26 -05:00
2010-05-27 22:16:05 -04:00
2010-05-27 22:15:33 -04:00
2010-03-19 08:05:10 +01:00
2010-05-27 22:15:33 -04:00
2009-09-24 07:21:03 -07:00
2010-05-21 18:31:16 -04:00
2010-05-21 18:31:16 -04:00
2010-05-11 17:43:58 +02:00
2010-03-06 11:26:29 -08:00
2010-05-21 18:31:16 -04:00
2010-03-08 16:55:37 +01:00
2010-05-21 18:31:17 -04:00
2010-05-18 08:57:00 +10:00
2010-05-21 18:31:17 -04:00
2010-06-10 19:08:34 +02:00
2010-05-27 09:12:56 -07:00
2010-03-12 15:52:32 -08:00
2010-05-21 18:31:17 -04:00
2010-06-01 12:42:12 +02:00