[SCM] Samba Shared Repository - branch v3-6-test updated

Jeremy Allison jra at samba.org
Mon Dec 20 19:05:30 MST 2010


The branch, v3-6-test has been updated
       via  a2956e7 Keep track of the sparse status of an open file handle. Allows bypass of strict allocation on sparse files. Files opened as POSIX opens are always sparse. (cherry picked from commit 3db2614ccd1948792cc403f0302c7516319461b2)
      from  132c57d Added call out to a Linux-compatible fallocate() when we need to extend a file allocation extent without changing end-of-file size. (cherry picked from commit 00d2d16262909fde2c144a504d7d554767b7fd45)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit a2956e7d2b66a828d7355841bcb3edfe188a12d3
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Dec 20 17:58:33 2010 -0800

    Keep track of the sparse status of an open file handle. Allows bypass of
    strict allocation on sparse files. Files opened as POSIX opens are always
    sparse.
    (cherry picked from commit 3db2614ccd1948792cc403f0302c7516319461b2)

-----------------------------------------------------------------------

Summary of changes:
 source3/include/smb.h         |    1 +
 source3/modules/vfs_default.c |    2 +-
 source3/smbd/dosmode.c        |    2 ++
 source3/smbd/fileio.c         |    3 ++-
 source3/smbd/open.c           |    9 +++++++++
 5 files changed, 15 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/smb.h b/source3/include/smb.h
index 2b397cc..8d12fb9 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -344,6 +344,7 @@ typedef struct files_struct {
 	bool initial_delete_on_close; /* Only set at NTCreateX if file was created. */
 	bool delete_on_close;
 	bool posix_open;
+	bool is_sparse;
 	struct smb_filename *fsp_name;
 
 	struct vfs_fsp_data *vfs_extension;
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 54f38c3..9cca349 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -895,7 +895,7 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_O
 
 	START_PROFILE(syscall_ftruncate);
 
-	if (lp_strict_allocate(SNUM(fsp->conn))) {
+	if (lp_strict_allocate(SNUM(fsp->conn)) && !fsp->is_sparse) {
 		result = strict_allocate_ftruncate(handle, fsp, len);
 		END_PROFILE(syscall_ftruncate);
 		return result;
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 2c6dcd0..cf95348 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -911,6 +911,8 @@ NTSTATUS file_set_sparse(connection_struct *conn,
 		     FILE_NOTIFY_CHANGE_ATTRIBUTES,
 		     fsp->fsp_name->base_name);
 
+	fsp->is_sparse = sparse;
+
 	return NT_STATUS_OK;
 }
 
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index aec6554..da40013 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -128,7 +128,8 @@ static ssize_t real_write_file(struct smb_request *req,
                 ret = vfs_write_data(req, fsp, data, n);
         } else {
 		fsp->fh->pos = pos;
-		if (pos && lp_strict_allocate(SNUM(fsp->conn))) {
+		if (pos && lp_strict_allocate(SNUM(fsp->conn) &&
+				!fsp->is_sparse)) {
 			if (vfs_fill_sparse(fsp, pos) == -1) {
 				return -1;
 			}
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 80756d6..32a08b5 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -2221,6 +2221,15 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
 		}
 	}
 
+	/* Determine sparse flag. */
+	if (posix_open) {
+		/* POSIX opens are sparse by default. */
+		fsp->is_sparse = true;
+	} else {
+		fsp->is_sparse = (file_existed &&
+			(existing_dos_attributes & FILE_ATTRIBUTE_SPARSE));
+	}
+
 	/*
 	 * Take care of inherited ACLs on created files - if default ACL not
 	 * selected.


-- 
Samba Shared Repository


More information about the samba-cvs mailing list