diff options
author | Niels de Vos <ndevos@redhat.com> | 2014-02-28 10:03:14 +0100 |
---|---|---|
committer | Niels de Vos <ndevos@redhat.com> | 2014-05-09 07:33:39 -0700 |
commit | a256094f34df6500bcd19845fd0f32a9f3690751 (patch) | |
tree | 3b7afbb9e12226c120188cf5ce45f7f0aeee43b4 /tests/performance/quick-read.t | |
parent | 94282fcae8ecb0d53399baa4e96f3aaa443979f0 (diff) |
write-behind: track filesize when doing extending writes
A program that calls mmap() on a newly created sparse file, may receive
a SIGBUS signal. If SIGBUS is not handled, a segmentation fault will
occur and the program will exit.
A bug in the write-behind translator can cause the creation of a sparse
file created with open(), seek(), write() to be cached. The last write()
may not be sent to the server, until write-behind deems this necessary.
* open(.., O_TRUNC, ...)/creat() the file, it is 0 bytes big
* seek() into the file, use offset 31
* write() 1 byte to the file
* the range from byte 0-30 are unwritten so called 'sparse'
The following illustration tries to capture this:
Legend:
[ = start of file
_ = unallocated/unwritten bytes
# = allocated bytes in the file
] = end of file
[_______________#]
| |
'- byte 0 '- byte 31
Without this change, reading from byte 0-30 will return an error, and
reading the same area through an mmap()'d pointer will trigger a SIGBUS.
Reading from this range did not trigger the outstanding write() to be
flushed. The brick that receives the read() (translated over the network
from mmap()) does not know that the file has been extended, and returns
-EINVAL. This error gets transported back from the brick to the
glusterfs-fuse client, and translated by the Linux kernel/VFS into
SIGBUS triggered by mmap().
In order to solve this, a new attribute to the wb_inode structure is
introduced; the current size of the file. All FOPs that can modify the
size, are expected to update wb_inode->size. This makes it possible for
extending writes with an offset bigger than EOF to mark the unwritten
area as modified/pending.
Cherry picked from commit b0515e2a4a08b657ef7e9715fb8c6222c700e78c:
> Change-Id: If5ba6646732e6be26568541ea9b12852a5d0b988
> BUG: 1058663
> Signed-off-by: Niels de Vos <ndevos@redhat.com>
> Reviewed-on: http://review.gluster.org/6835
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
> Reviewed-by: Anand Avati <avati@redhat.com>
Change-Id: Ic73288202c6cb37d8c066628e9c489c6fade49bd
BUG: 1071191
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/7166
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'tests/performance/quick-read.t')
0 files changed, 0 insertions, 0 deletions