[SCM] The rsync repository. - branch master updated
Rsync CVS commit messages
rsync-cvs at lists.samba.org
Fri Jan 18 16:38:28 MST 2013
The branch, master has been updated
via 0ae9256 Align fileio's map_ptr() reads. Fixes bug 8177.
via 42f759a Reformat a few things for wider lines.
from e1ded58 Improve handling of existing files for alt-dest opts. Fixes bug #5644.
;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 0ae92567ed5381b3f92266562129aa7adc47025d
Author: Wayne Davison <wayned at samba.org>
Date: Fri Jan 18 15:07:03 2013 -0800
Align fileio's map_ptr() reads. Fixes bug 8177.
commit 42f759ad9ae0a7a1ea0c2dfcce01180fa17071af
Author: Wayne Davison <wayned at samba.org>
Date: Fri Jan 18 15:18:58 2013 -0800
Reformat a few things for wider lines.
-----------------------------------------------------------------------
Summary of changes:
fileio.c | 34 +++++++++++++++++++---------------
1 files changed, 19 insertions(+), 15 deletions(-)
Changeset truncated at 500 lines:
diff --git a/fileio.c b/fileio.c
index d8ac097..c56b0d9 100644
--- a/fileio.c
+++ b/fileio.c
@@ -26,6 +26,13 @@
#define ENODATA EAGAIN
#endif
+/* We want all reads to be aligned on 1K boundries. */
+#define ALIGN_BOUNDRY 1024
+/* How far past the boundary is an offset? */
+#define ALIGNED_OVERSHOOT(oft) ((oft) & (ALIGN_BOUNDRY-1))
+/* Round up a length to the next boundary */
+#define ALIGNED_LENGTH(len) ((((len) - 1) | (ALIGN_BOUNDRY-1)) + 1)
+
extern int sparse_files;
static OFF_T sparse_seek = 0;
@@ -159,8 +166,7 @@ int write_file(int f, char *buf, int len)
* It gives sliding window access to a file. mmap() is not used because of
* the possibility of another program (such as a mailer) truncating the
* file thus giving us a SIGBUS. */
-struct map_struct *map_file(int fd, OFF_T len, int32 read_size,
- int32 blk_size)
+struct map_struct *map_file(int fd, OFF_T len, int32 read_size, int32 blk_size)
{
struct map_struct *map;
@@ -172,7 +178,7 @@ struct map_struct *map_file(int fd, OFF_T len, int32 read_size,
map->fd = fd;
map->file_size = len;
- map->def_window_size = read_size;
+ map->def_window_size = ALIGNED_LENGTH(read_size);
return map;
}
@@ -181,9 +187,8 @@ struct map_struct *map_file(int fd, OFF_T len, int32 read_size,
/* slide the read window in the file */
char *map_ptr(struct map_struct *map, OFF_T offset, int32 len)
{
- int32 nread;
OFF_T window_start, read_start;
- int32 window_size, read_size, read_offset;
+ int32 window_size, read_size, read_offset, align_fudge;
if (len == 0)
return NULL;
@@ -198,12 +203,13 @@ char *map_ptr(struct map_struct *map, OFF_T offset, int32 len)
return map->p + (offset - map->p_offset);
/* nope, we are going to have to do a read. Work out our desired window */
- window_start = offset;
+ align_fudge = (int32)ALIGNED_OVERSHOOT(offset);
+ window_start = offset - align_fudge;
window_size = map->def_window_size;
if (window_start + window_size > map->file_size)
window_size = (int32)(map->file_size - window_start);
- if (len > window_size)
- window_size = len;
+ if (window_size < len + align_fudge)
+ window_size = ALIGNED_LENGTH(len + align_fudge);
/* make sure we have allocated enough memory for the window */
if (window_size > map->p_size) {
@@ -213,11 +219,9 @@ char *map_ptr(struct map_struct *map, OFF_T offset, int32 len)
map->p_size = window_size;
}
- /* Now try to avoid re-reading any bytes by reusing any bytes
- * from the previous buffer. */
- if (window_start >= map->p_offset &&
- window_start < map->p_offset + map->p_len &&
- window_start + window_size >= map->p_offset + map->p_len) {
+ /* Now try to avoid re-reading any bytes by reusing any bytes from the previous buffer. */
+ if (window_start >= map->p_offset && window_start < map->p_offset + map->p_len
+ && window_start + window_size >= map->p_offset + map->p_len) {
read_start = map->p_offset + map->p_len;
read_offset = (int32)(read_start - window_start);
read_size = window_size - read_offset;
@@ -247,7 +251,7 @@ char *map_ptr(struct map_struct *map, OFF_T offset, int32 len)
map->p_len = window_size;
while (read_size > 0) {
- nread = read(map->fd, map->p + read_offset, read_size);
+ int32 nread = read(map->fd, map->p + read_offset, read_size);
if (nread <= 0) {
if (!map->status)
map->status = nread ? errno : ENODATA;
@@ -261,7 +265,7 @@ char *map_ptr(struct map_struct *map, OFF_T offset, int32 len)
read_size -= nread;
}
- return map->p;
+ return map->p + align_fudge;
}
--
The rsync repository.
More information about the rsync-cvs
mailing list