Bug 1268 - Renaming large file accross different device potentially cause session-out.
Summary: Renaming large file accross different device potentially cause session-out.
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: File Services (show other bugs)
Version: 3.0.2a
Hardware: All All
: P3 normal
Target Milestone: none
Assignee: Samba Bugzilla Account
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-16 03:15 UTC by YAMASAKI Hiroyuki
Modified: 2006-04-08 11:46 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description YAMASAKI Hiroyuki 2004-04-16 03:15:13 UTC
Sorry for my poor english.

In smbd/vfs-wrap.c/vfswrap_rename(), if rename(2) return EXDEV error,then
call copy_reg() to emulate rename accross different device by copy and unlink.
---------------------------------------------------------------------------
int vfswrap_rename(vfs_handle_struct *handle, connection_struct *conn, const 
char *old, const char *new)
{
	int result;

	START_PROFILE(syscall_rename);
	result = rename(old, new);
	if (errno == EXDEV) {
		/* Rename across filesystems needed. */
		result = copy_reg(old, new);
	}

	END_PROFILE(syscall_rename);
	return result;
}
---------------------------------------------------------------------------

But, if the file is very large(ex. 2GB), copy_reg() is a long time in copying 
file by tranfer_file().  So, client PC is session-timeout.

In case of Windows Server with NTFS junction-point mounted volume, rename
(SMBmv) request accross different volumes is failed and returned error is   
NTStatus STATUS_NOT_SAME_DEVICE(0xc00000d4) or DosStatus ERRdiffdevice
(0x0011).  When windows client receive the error, windows client emulate rename 
by open both(new and old) files, and copy data from old file to new one ,and 
unlink old file,and adjust timestamp. 

So, I think if rename(2) in vfswrap_rename() return EXDEV, should just return 
EXDEV without copy_reg() as below.  
---------------------------------------------------------------------------
int vfswrap_rename(vfs_handle_struct *handle, connection_struct *conn, const 
char *old, const char *new)
{
	int result;

	START_PROFILE(syscall_rename);
	result = rename(old, new);
#if 0
	if (errno == EXDEV) {
		/* Rename across filesystems needed. */
		result = copy_reg(old, new);
	}
#endif
	END_PROFILE(syscall_rename);
	return result;
}
---------------------------------------------------------------------------

Because libsmb/errormap.c/unix_dos_nt_errmap have below definition.  error 
EXDEV is translated to NT_STATUS_NOT_SAME_DEVICE or ERRdiffdevice.
------------------------------------------------------------------------
#ifdef EXDEV
	{ EXDEV, ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE },
#endif
------------------------------------------------------------------------
Comment 1 Gerald (Jerry) Carter (dead mail address) 2005-11-14 09:26:16 UTC
database cleanup
Comment 2 Gerald (Jerry) Carter (dead mail address) 2006-04-08 11:46:57 UTC
please reopen if the bug still exists in a current release.