svn commit: samba r5635 - in trunk/source: include param smbd
jra at samba.org
jra at samba.org
Thu Mar 3 03:43:42 GMT 2005
Author: jra
Date: 2005-03-03 03:43:41 +0000 (Thu, 03 Mar 2005)
New Revision: 5635
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5635
Log:
Re-add the allocation size - parameterized by share as
"allocation roundup size", by default set as 1Mb. From
advice by BlueArc about Windows client behaviour. VC++
people can set this to zero to turn it off.
Jeremy.
Modified:
trunk/source/include/local.h
trunk/source/include/smb_macros.h
trunk/source/include/trans2.h
trunk/source/param/loadparm.c
trunk/source/smbd/nttrans.c
trunk/source/smbd/trans2.c
Changeset:
Modified: trunk/source/include/local.h
===================================================================
--- trunk/source/include/local.h 2005-03-03 02:07:00 UTC (rev 5634)
+++ trunk/source/include/local.h 2005-03-03 03:43:41 UTC (rev 5635)
@@ -198,6 +198,9 @@
/* the maximum age in seconds of a password. Should be a lp_ parameter */
#define MAX_PASSWORD_AGE (21*24*60*60)
+/* Default allocation roundup. */
+#define SMB_ROUNDUP_ALLOCATION_SIZE 0x100000
+
/* shall we deny oplocks to clients that get timeouts? */
#define FASCIST_OPLOCK_BACKOFF 1
Modified: trunk/source/include/smb_macros.h
===================================================================
--- trunk/source/include/smb_macros.h 2005-03-03 02:07:00 UTC (rev 5634)
+++ trunk/source/include/smb_macros.h 2005-03-03 03:43:41 UTC (rev 5635)
@@ -178,6 +178,8 @@
/* this is how errors are generated */
#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,__LINE__,__FILE__)
+#define SMB_ROUNDUP(x,r) ( ((x)%(r)) ? ( (((x)+(r))/(r))*(r) ) : (x))
+
/* Extra macros added by Ying Chen at IBM - speed increase by inlining. */
#define smb_buf(buf) (((char *)(buf)) + smb_size + CVAL(buf,smb_wct)*2)
#define smb_buflen(buf) (SVAL(buf,smb_vwv0 + (int)CVAL(buf, smb_wct)*2))
Modified: trunk/source/include/trans2.h
===================================================================
--- trunk/source/include/trans2.h 2005-03-03 02:07:00 UTC (rev 5634)
+++ trunk/source/include/trans2.h 2005-03-03 03:43:41 UTC (rev 5635)
@@ -536,4 +536,23 @@
#define SMB_POSIX_ACL_ENTRY_SIZE 10
#define SMB_POSIX_IGNORE_ACE_ENTRIES 0xFFFF
+
+/* The query/set info levels for POSIX EA's. */
+#define SMB_QUERY_POSIX_EA 0x205
+#define SMB_SET_POSIX_EA 0x205
+
+/* The query/set info levels for POSIX fcntl locks. */
+#define SMB_QUERY_POSIX_LOCK 0x206
+#define SMB_SET_POSIX_LOCK 0x206
+
+/* What a lock get/set request looks like. */
+/* Wire format is (all little endian) :
+
+[2 bytes] type - 0 = READ/1 = WRITE/2 = UNOCK
+[64 bytes] start position
+[64 bytes] length (zero means to end of file)
+[64 bytes] lock context
+[4 bytes] timeout in ms.
+
+*/
#endif
Modified: trunk/source/param/loadparm.c
===================================================================
--- trunk/source/param/loadparm.c 2005-03-03 02:07:00 UTC (rev 5634)
+++ trunk/source/param/loadparm.c 2005-03-03 03:43:41 UTC (rev 5635)
@@ -435,6 +435,7 @@
BOOL bMap_acl_inherit;
BOOL bAfs_Share;
BOOL bEASupport;
+ int iallocation_roundup_size;
param_opt_struct *param_opt;
char dummy[3]; /* for alignment */
@@ -560,6 +561,7 @@
False, /* bMap_acl_inherit */
False, /* bAfs_Share */
False, /* bEASupport */
+ SMB_ROUNDUP_ALLOCATION_SIZE, /* iallocation_roundup_size */
NULL, /* Parametric options */
@@ -907,6 +909,7 @@
{N_("Protocol Options"), P_SEP, P_SEPARATOR},
+ {"allocation roundup size", P_INTEGER, P_LOCAL, &sDefault.iallocation_roundup_size, NULL, NULL, FLAG_ADVANCED},
{"smb ports", P_STRING, P_GLOBAL, &Globals.smb_ports, NULL, NULL, FLAG_ADVANCED},
{"large readwrite", P_BOOL, P_GLOBAL, &Globals.bLargeReadwrite, NULL, NULL, FLAG_ADVANCED},
{"max protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, FLAG_ADVANCED},
@@ -1977,6 +1980,7 @@
FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
FN_LOCAL_INTEGER(lp_write_cache_size, iWriteCacheSize)
FN_LOCAL_INTEGER(lp_block_size, iBlock_size)
+FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size);
FN_LOCAL_CHAR(lp_magicchar, magic_char)
FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
FN_GLOBAL_INTEGER(lp_winbind_max_idle_children, &Globals.winbind_max_idle_children)
Modified: trunk/source/smbd/nttrans.c
===================================================================
--- trunk/source/smbd/nttrans.c 2005-03-03 02:07:00 UTC (rev 5634)
+++ trunk/source/smbd/nttrans.c 2005-03-03 03:43:41 UTC (rev 5635)
@@ -808,7 +808,8 @@
* If it's a request for a directory open, deal with it separately.
*/
- if(create_options & FILE_DIRECTORY_FILE) {
+ if((create_options & FILE_DIRECTORY_FILE)||
+ (IS_VALID_STAT(&sbuf) && S_ISDIR(sbuf.st_mode))) {
oplock_request = 0;
/* Can't open a temp directory. IFS kit test. */
@@ -932,7 +933,7 @@
allocation_size |= (((SMB_BIG_UINT)IVAL(inbuf,smb_ntcreate_AllocationSize + 4)) << 32);
#endif
if (allocation_size && (allocation_size > (SMB_BIG_UINT)file_len)) {
- fsp->initial_allocation_size = allocation_size;
+ fsp->initial_allocation_size = smb_roundup(fsp->conn, allocation_size);
if (fsp->is_directory) {
close_file(fsp,False);
END_PROFILE(SMBntcreateX);
@@ -945,7 +946,7 @@
return ERROR_NT(NT_STATUS_DISK_FULL);
}
} else {
- fsp->initial_allocation_size = (SMB_BIG_UINT)file_len;
+ fsp->initial_allocation_size = smb_roundup(fsp->conn,(SMB_BIG_UINT)file_len);
}
/*
@@ -1368,7 +1369,8 @@
* If it's a request for a directory open, deal with it separately.
*/
- if(create_options & FILE_DIRECTORY_FILE) {
+ if((create_options & FILE_DIRECTORY_FILE)||
+ (IS_VALID_STAT(&sbuf) && S_ISDIR(sbuf.st_mode))) {
/* Can't open a temp directory. IFS kit test. */
if (file_attributes & FILE_ATTRIBUTE_TEMPORARY) {
@@ -1475,7 +1477,7 @@
allocation_size |= (((SMB_BIG_UINT)IVAL(params,16)) << 32);
#endif
if (allocation_size && (allocation_size > file_len)) {
- fsp->initial_allocation_size = allocation_size;
+ fsp->initial_allocation_size = smb_roundup(fsp->conn, allocation_size);
if (fsp->is_directory) {
close_file(fsp,False);
END_PROFILE(SMBntcreateX);
@@ -1487,7 +1489,7 @@
return ERROR_NT(NT_STATUS_DISK_FULL);
}
} else {
- fsp->initial_allocation_size = (SMB_BIG_UINT)file_len;
+ fsp->initial_allocation_size = smb_roundup(fsp->conn, (SMB_BIG_UINT)file_len);
}
/* Realloc the size of parameters and data we will return */
Modified: trunk/source/smbd/trans2.c
===================================================================
--- trunk/source/smbd/trans2.c 2005-03-03 02:07:00 UTC (rev 5634)
+++ trunk/source/smbd/trans2.c 2005-03-03 03:43:41 UTC (rev 5635)
@@ -33,6 +33,23 @@
#define DIR_ENTRY_SAFETY_MARGIN 4096
/********************************************************************
+ Roundup a value to the nearest allocation roundup size boundary.
+ Only do this for Windows clients.
+********************************************************************/
+
+SMB_BIG_UINT smb_roundup(connection_struct *conn, SMB_BIG_UINT val)
+{
+ SMB_BIG_UINT rval = lp_allocation_roundup_size(SNUM(conn));
+
+ /* Only roundup for Windows clients. */
+ enum remote_arch_types ra_type = get_remote_arch();
+ if (rval && (ra_type != RA_SAMBA) && (ra_type != RA_CIFSFS)) {
+ val = SMB_ROUNDUP(val,rval);
+ }
+ return val;
+}
+
+/********************************************************************
Given a stat buffer return the allocated size on disk, taking into
account sparse files.
********************************************************************/
@@ -50,7 +67,7 @@
if (!ret && fsp && fsp->initial_allocation_size)
ret = fsp->initial_allocation_size;
- return ret;
+ return smb_roundup(fsp->conn, ret);
}
/****************************************************************************
@@ -3333,6 +3350,10 @@
DEBUG(10,("call_trans2setfilepathinfo: Set file allocation info for file %s to %.0f\n",
fname, (double)allocation_size ));
+ if (allocation_size) {
+ allocation_size = smb_roundup(conn, allocation_size);
+ }
+
if(allocation_size != get_file_size(sbuf)) {
SMB_STRUCT_STAT new_sbuf;
More information about the samba-cvs
mailing list