svn commit: samba r22111 - in branches: SAMBA_3_0/source/modules
SAMBA_3_0_25/source/modules
jra at samba.org
jra at samba.org
Fri Apr 6 21:12:45 GMT 2007
Author: jra
Date: 2007-04-06 21:12:44 +0000 (Fri, 06 Apr 2007)
New Revision: 22111
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22111
Log:
Allow readahead params to use size suffixes as K,M, etc.
Jeremy.
Modified:
branches/SAMBA_3_0/source/modules/vfs_readahead.c
branches/SAMBA_3_0_25/source/modules/vfs_readahead.c
Changeset:
Modified: branches/SAMBA_3_0/source/modules/vfs_readahead.c
===================================================================
--- branches/SAMBA_3_0/source/modules/vfs_readahead.c 2007-04-06 21:05:55 UTC (rev 22110)
+++ branches/SAMBA_3_0/source/modules/vfs_readahead.c 2007-04-06 21:12:44 UTC (rev 22111)
@@ -28,6 +28,30 @@
* 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 @@
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 @@
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",
Modified: branches/SAMBA_3_0_25/source/modules/vfs_readahead.c
===================================================================
--- branches/SAMBA_3_0_25/source/modules/vfs_readahead.c 2007-04-06 21:05:55 UTC (rev 22110)
+++ branches/SAMBA_3_0_25/source/modules/vfs_readahead.c 2007-04-06 21:12:44 UTC (rev 22111)
@@ -28,6 +28,30 @@
* 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 @@
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 @@
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",
More information about the samba-cvs
mailing list