summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-04-06 21:12:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:19:13 -0500
commit4c6dfcf95429f27a194e0d6b5ac568d94aa40adc (patch)
treedc0b2dfb2b43e70cd89532a9476a4391d7c0b375
parentccb99cafa7c806906d1f35f9ee3dcd4e15e69204 (diff)
downloadsamba-4c6dfcf95429f27a194e0d6b5ac568d94aa40adc.tar.gz
samba-4c6dfcf95429f27a194e0d6b5ac568d94aa40adc.tar.bz2
samba-4c6dfcf95429f27a194e0d6b5ac568d94aa40adc.zip
r22111: Allow readahead params to use size suffixes as K,M, etc.
Jeremy. (This used to be commit e296f07e1d3a14fe05a444ccdc752cd945fee5bc)
-rw-r--r--source3/modules/vfs_readahead.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/source3/modules/vfs_readahead.c b/source3/modules/vfs_readahead.c
index 5b08f004c4..2663326c99 100644
--- a/source3/modules/vfs_readahead.c
+++ b/source3/modules/vfs_readahead.c
@@ -28,6 +28,30 @@ static BOOL didmsg;
* the buffer cache to be filled in advance.
*/
+static unsigned long get_offset_boundary(struct vfs_handle_struct *handle)
+{
+ SMB_OFF_T off_bound = conv_str_size(lp_parm_const_string(SNUM(handle->conn),
+ "readahead",
+ "offset",
+ NULL));
+ if (off_bound == 0) {
+ off_bound = 0x80000;
+ }
+ return (unsigned long)off_bound;
+}
+
+static unsigned long get_offset_length(struct vfs_handle_struct *handle, unsigned long def_val)
+{
+ SMB_OFF_T len = conv_str_size(lp_parm_const_string(SNUM(handle->conn),
+ "readahead",
+ "length",
+ NULL));
+ if (len == 0) {
+ len = def_val;
+ }
+ return (unsigned long)len;
+}
+
static ssize_t readahead_sendfile(struct vfs_handle_struct *handle,
int tofd,
files_struct *fsp,
@@ -36,9 +60,9 @@ static ssize_t readahead_sendfile(struct vfs_handle_struct *handle,
SMB_OFF_T offset,
size_t count)
{
- unsigned long off_bound = lp_parm_ulong(SNUM(handle->conn), "readahead", "offset", 0x80000);
+ unsigned long off_bound = get_offset_boundary(handle);
if ( offset % off_bound == 0) {
- unsigned long len = lp_parm_ulong(SNUM(handle->conn), "readahead", "length", off_bound);
+ unsigned long len = get_offset_length(handle, off_bound);
#if defined(HAVE_LINUX_READAHEAD)
int err = readahead(fromfd, offset, (size_t)len);
DEBUG(10,("readahead_sendfile: readahead on fd %u, offset %llu, len %u returned %d\n",
@@ -76,9 +100,9 @@ static ssize_t readahead_pread(vfs_handle_struct *handle,
size_t count,
SMB_OFF_T offset)
{
- unsigned long off_bound = lp_parm_ulong(SNUM(handle->conn), "readahead", "offset", 0x80000);
+ unsigned long off_bound = get_offset_boundary(handle);
if ( offset % off_bound == 0) {
- unsigned long len = lp_parm_ulong(SNUM(handle->conn), "readahead", "length", off_bound);
+ unsigned long len = get_offset_length(handle, off_bound);
#if defined(HAVE_LINUX_READAHEAD)
int err = readahead(fd, offset, (size_t)len);
DEBUG(10,("readahead_pread: readahead on fd %u, offset %llu, len %u returned %d\n",