[SCM] Samba Shared Repository - branch v4-0-test updated - release-4-0-0alpha2-1086-g608e5cd

Stefan Metzmacher metze at samba.org
Thu Feb 28 07:33:25 GMT 2008


The branch, v4-0-test has been updated
       via  608e5cd881d64b8db9146dfc4b3a1778a93a0f8e (commit)
       via  e699633db2d377a9077ff490208da277e250239b (commit)
       via  73f12be7c6a648d4d5336328a340510ac7b1d6de (commit)
       via  c78451ce0618de92321430d2b50f9a8172d283f4 (commit)
       via  fc27730bad24e8dddaa2e7f754a16811e38a2f60 (commit)
      from  582073eff1f21f81abb3e5f1ce2eca4ebef56a00 (commit)

http://gitweb.samba.org/?samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit 608e5cd881d64b8db9146dfc4b3a1778a93a0f8e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Feb 27 22:22:56 2008 +0100

    pvfs_open: fix callers of odb_get_delete_on_close()
    
    metze

commit e699633db2d377a9077ff490208da277e250239b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Feb 27 22:16:55 2008 +0100

    opendb: only return delete_on_close on odb_get_delete_on_close()
    
    metze

commit 73f12be7c6a648d4d5336328a340510ac7b1d6de
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Feb 27 22:22:10 2008 +0100

    pvfs: remove unused args from pvfs_delete_on_close_set()
    
    metze

commit c78451ce0618de92321430d2b50f9a8172d283f4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Feb 27 21:52:52 2008 +0100

    pvfs_open: use the delete_path of odb_close_file()
    
    metze

commit fc27730bad24e8dddaa2e7f754a16811e38a2f60
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Feb 27 21:50:51 2008 +0100

    opendb: return the path that should be deleted in odb_close_file()
    
    That means the last close returns the path name if the
    delete_on_close flag is set.
    
    metze

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

Summary of changes:
 source/cluster/ctdb/opendb_ctdb.c   |   29 ++++++-----
 source/ntvfs/common/opendb.c        |   10 ++--
 source/ntvfs/common/opendb.h        |    6 +-
 source/ntvfs/common/opendb_tdb.c    |   31 ++++++------
 source/ntvfs/posix/pvfs_open.c      |   91 ++++++++++++++--------------------
 source/ntvfs/posix/pvfs_qfileinfo.c |    6 +-
 6 files changed, 80 insertions(+), 93 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/cluster/ctdb/opendb_ctdb.c b/source/cluster/ctdb/opendb_ctdb.c
index 3dfc681..3d67162 100644
--- a/source/cluster/ctdb/opendb_ctdb.c
+++ b/source/cluster/ctdb/opendb_ctdb.c
@@ -409,10 +409,12 @@ static NTSTATUS odb_ctdb_open_file_pending(struct odb_lock *lck, void *private)
 /*
   remove a opendb entry
 */
-static NTSTATUS odb_ctdb_close_file(struct odb_lock *lck, void *file_handle)
+static NTSTATUS odb_ctdb_close_file(struct odb_lock *lck, void *file_handle,
+				    const char **_delete_path)
 {
 	struct odb_context *odb = lck->odb;
 	struct opendb_file file;
+	const char *delete_path = NULL;
 	int i;
 	NTSTATUS status;
 
@@ -448,6 +450,15 @@ static NTSTATUS odb_ctdb_close_file(struct odb_lock *lck, void *file_handle)
 	file.num_pending = 0;
 
 	file.num_entries--;
+
+	if (file.num_entries == 0 && file.delete_on_close) {
+		delete_path = talloc_strdup(lck, file.path);
+		NT_STATUS_HAVE_NO_MEMORY(delete_path);
+	}
+
+	if (_delete_path) {
+		*_delete_path = delete_path;
+	}
 	
 	return odb_push_record(lck, &file);
 }
@@ -552,20 +563,20 @@ static NTSTATUS odb_ctdb_set_delete_on_close(struct odb_lock *lck, bool del_on_c
   people still have the file open
 */
 static NTSTATUS odb_ctdb_get_delete_on_close(struct odb_context *odb, 
-					    DATA_BLOB *key, bool *del_on_close, 
-					    int *open_count, char **path)
+					    DATA_BLOB *key, bool *del_on_close)
 {
 	NTSTATUS status;
 	struct opendb_file file;
 	struct odb_lock *lck;
 
+	(*del_on_close) = false;
+
 	lck = odb_lock(odb, odb, key);
 	NT_STATUS_HAVE_NO_MEMORY(lck);
 
 	status = odb_pull_record(lck, &file);
 	if (NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)) {
 		talloc_free(lck);
-		(*del_on_close) = false;
 		return NT_STATUS_OK;
 	}
 	if (!NT_STATUS_IS_OK(status)) {
@@ -574,16 +585,6 @@ static NTSTATUS odb_ctdb_get_delete_on_close(struct odb_context *odb,
 	}
 
 	(*del_on_close) = file.delete_on_close;
-	if (open_count != NULL) {
-		(*open_count) = file.num_entries;
-	}
-	if (path != NULL) {
-		*path = talloc_strdup(odb, file.path);
-		NT_STATUS_HAVE_NO_MEMORY(*path);
-		if (file.num_entries == 1 && file.entries[0].delete_on_close) {
-			(*del_on_close) = true;
-		}
-	}
 
 	talloc_free(lck);
 
diff --git a/source/ntvfs/common/opendb.c b/source/ntvfs/common/opendb.c
index 36144d0..d8cb676 100644
--- a/source/ntvfs/common/opendb.c
+++ b/source/ntvfs/common/opendb.c
@@ -118,9 +118,10 @@ _PUBLIC_ NTSTATUS odb_open_file_pending(struct odb_lock *lck, void *private)
 /*
   remove a opendb entry
 */
-_PUBLIC_ NTSTATUS odb_close_file(struct odb_lock *lck, void *file_handle)
+_PUBLIC_ NTSTATUS odb_close_file(struct odb_lock *lck, void *file_handle,
+				 const char **delete_path)
 {
-	return ops->odb_close_file(lck, file_handle);
+	return ops->odb_close_file(lck, file_handle, delete_path);
 }
 
 
@@ -154,10 +155,9 @@ _PUBLIC_ NTSTATUS odb_set_delete_on_close(struct odb_lock *lck, bool del_on_clos
   people still have the file open
 */
 _PUBLIC_ NTSTATUS odb_get_delete_on_close(struct odb_context *odb, 
-					  DATA_BLOB *key, bool *del_on_close, 
-					  int *open_count, char **path)
+					  DATA_BLOB *key, bool *del_on_close)
 {
-	return ops->odb_get_delete_on_close(odb, key, del_on_close, open_count, path);
+	return ops->odb_get_delete_on_close(odb, key, del_on_close);
 }
 
 
diff --git a/source/ntvfs/common/opendb.h b/source/ntvfs/common/opendb.h
index 9591bcf..33f2e1c 100644
--- a/source/ntvfs/common/opendb.h
+++ b/source/ntvfs/common/opendb.h
@@ -32,13 +32,13 @@ struct opendb_ops {
 				  uint32_t open_disposition, bool break_to_none,
 				  uint32_t oplock_level, uint32_t *oplock_granted);
 	NTSTATUS (*odb_open_file_pending)(struct odb_lock *lck, void *private);
-	NTSTATUS (*odb_close_file)(struct odb_lock *lck, void *file_handle);
+	NTSTATUS (*odb_close_file)(struct odb_lock *lck, void *file_handle,
+				   const char **delete_path);
 	NTSTATUS (*odb_remove_pending)(struct odb_lock *lck, void *private);
 	NTSTATUS (*odb_rename)(struct odb_lock *lck, const char *path);
 	NTSTATUS (*odb_set_delete_on_close)(struct odb_lock *lck, bool del_on_close);
 	NTSTATUS (*odb_get_delete_on_close)(struct odb_context *odb, 
-					    DATA_BLOB *key, bool *del_on_close, 
-					    int *open_count, char **path);
+					    DATA_BLOB *key, bool *del_on_close);
 	NTSTATUS (*odb_can_open)(struct odb_lock *lck,
 				 uint32_t stream_id, uint32_t share_access,
 				 uint32_t access_mask, bool delete_on_close,
diff --git a/source/ntvfs/common/opendb_tdb.c b/source/ntvfs/common/opendb_tdb.c
index a51c823..37c1c08 100644
--- a/source/ntvfs/common/opendb_tdb.c
+++ b/source/ntvfs/common/opendb_tdb.c
@@ -527,10 +527,12 @@ static NTSTATUS odb_tdb_open_file_pending(struct odb_lock *lck, void *private)
 /*
   remove a opendb entry
 */
-static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle)
+static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle,
+				   const char **_delete_path)
 {
 	struct odb_context *odb = lck->odb;
 	struct opendb_file file;
+	const char *delete_path = NULL;
 	int i;
 	NTSTATUS status;
 
@@ -566,7 +568,16 @@ static NTSTATUS odb_tdb_close_file(struct odb_lock *lck, void *file_handle)
 	file.num_pending = 0;
 
 	file.num_entries--;
-	
+
+	if (file.num_entries == 0 && file.delete_on_close) {
+		delete_path = talloc_strdup(lck, file.path);
+		NT_STATUS_HAVE_NO_MEMORY(delete_path);
+	}
+
+	if (_delete_path) {
+		*_delete_path = delete_path;
+	}
+
 	return odb_push_record(lck, &file);
 }
 
@@ -723,20 +734,20 @@ static NTSTATUS odb_tdb_set_delete_on_close(struct odb_lock *lck, bool del_on_cl
   people still have the file open
 */
 static NTSTATUS odb_tdb_get_delete_on_close(struct odb_context *odb, 
-					    DATA_BLOB *key, bool *del_on_close, 
-					    int *open_count, char **path)
+					    DATA_BLOB *key, bool *del_on_close)
 {
 	NTSTATUS status;
 	struct opendb_file file;
 	struct odb_lock *lck;
 
+	(*del_on_close) = false;
+
 	lck = odb_lock(odb, odb, key);
 	NT_STATUS_HAVE_NO_MEMORY(lck);
 
 	status = odb_pull_record(lck, &file);
 	if (NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)) {
 		talloc_free(lck);
-		(*del_on_close) = false;
 		return NT_STATUS_OK;
 	}
 	if (!NT_STATUS_IS_OK(status)) {
@@ -745,16 +756,6 @@ static NTSTATUS odb_tdb_get_delete_on_close(struct odb_context *odb,
 	}
 
 	(*del_on_close) = file.delete_on_close;
-	if (open_count != NULL) {
-		(*open_count) = file.num_entries;
-	}
-	if (path != NULL) {
-		*path = talloc_strdup(odb, file.path);
-		NT_STATUS_HAVE_NO_MEMORY(*path);
-		if (file.num_entries == 1 && file.entries[0].delete_on_close) {
-			(*del_on_close) = true;
-		}
-	}
 
 	talloc_free(lck);
 
diff --git a/source/ntvfs/posix/pvfs_open.c b/source/ntvfs/posix/pvfs_open.c
index a01352f..740a0a9 100644
--- a/source/ntvfs/posix/pvfs_open.c
+++ b/source/ntvfs/posix/pvfs_open.c
@@ -50,29 +50,10 @@ struct pvfs_file *pvfs_find_fd(struct pvfs_state *pvfs,
 */
 static int pvfs_dir_handle_destructor(struct pvfs_file_handle *h)
 {
-	int open_count;
-	char *path = NULL;
-
-	if (h->name->stream_name == NULL && 
-	    pvfs_delete_on_close_set(h->pvfs, h, &open_count, &path) &&
-	    open_count == 1) {
-		NTSTATUS status;
-		status = pvfs_xattr_unlink_hook(h->pvfs, path);
-		if (!NT_STATUS_IS_OK(status)) {
-			DEBUG(0,("Warning: xattr unlink hook failed for '%s' - %s\n",
-				 path, nt_errstr(status)));
-		}
-		if (rmdir(path) != 0) {
-			DEBUG(0,("pvfs_dir_handle_destructor: failed to rmdir '%s' - %s\n", 
-				 path, strerror(errno)));
-		}
-	}
-
-	talloc_free(path);
-
 	if (h->have_opendb_entry) {
 		struct odb_lock *lck;
 		NTSTATUS status;
+		const char *delete_path = NULL;
 
 		lck = odb_lock(h, h->pvfs->odb_context, &h->odb_locking_key);
 		if (lck == NULL) {
@@ -80,12 +61,24 @@ static int pvfs_dir_handle_destructor(struct pvfs_file_handle *h)
 			return 0;
 		}
 
-		status = odb_close_file(lck, h);
+		status = odb_close_file(lck, h, &delete_path);
 		if (!NT_STATUS_IS_OK(status)) {
-			DEBUG(0,("Unable to remove opendb entry for '%s' - %s\n", 
+			DEBUG(0,("Unable to remove opendb entry for '%s' - %s\n",
 				 h->name->full_name, nt_errstr(status)));
 		}
 
+		if (h->name->stream_name == NULL && delete_path) {
+			status = pvfs_xattr_unlink_hook(h->pvfs, delete_path);
+			if (!NT_STATUS_IS_OK(status)) {
+				DEBUG(0,("Warning: xattr unlink hook failed for '%s' - %s\n",
+					 delete_path, nt_errstr(status)));
+			}
+			if (rmdir(delete_path) != 0) {
+				DEBUG(0,("pvfs_dir_handle_destructor: failed to rmdir '%s' - %s\n",
+					 delete_path, strerror(errno)));
+			}
+		}
+
 		talloc_free(lck);
 	}
 
@@ -410,9 +403,6 @@ cleanup_delete:
 */
 static int pvfs_handle_destructor(struct pvfs_file_handle *h)
 {
-	int open_count;
-	char *path = NULL;
-
 	/* the write time is no longer sticky */
 	if (h->sticky_write_time) {
 		NTSTATUS status;
@@ -441,32 +431,10 @@ static int pvfs_handle_destructor(struct pvfs_file_handle *h)
 		h->fd = -1;
 	}
 
-	if (h->name->stream_name == NULL && 
-	    h->open_completed &&
-	    pvfs_delete_on_close_set(h->pvfs, h, &open_count, &path) &&
-	    open_count == 1) {
-		NTSTATUS status;
-		status = pvfs_xattr_unlink_hook(h->pvfs, path);
-		if (!NT_STATUS_IS_OK(status)) {
-			DEBUG(0,("Warning: xattr unlink hook failed for '%s' - %s\n",
-				 path, nt_errstr(status)));
-		}
-		if (unlink(path) != 0) {
-			DEBUG(0,("pvfs_close: failed to delete '%s' - %s\n", 
-				 path, strerror(errno)));
-		} else {
-			notify_trigger(h->pvfs->notify_context, 
-				       NOTIFY_ACTION_REMOVED, 
-				       FILE_NOTIFY_CHANGE_FILE_NAME,
-				       path);
-		}
-	}
-
-	talloc_free(path);
-
 	if (h->have_opendb_entry) {
 		struct odb_lock *lck;
 		NTSTATUS status;
+		const char *delete_path = NULL;
 
 		lck = odb_lock(h, h->pvfs->odb_context, &h->odb_locking_key);
 		if (lck == NULL) {
@@ -474,12 +442,30 @@ static int pvfs_handle_destructor(struct pvfs_file_handle *h)
 			return 0;
 		}
 
-		status = odb_close_file(lck, h);
+		status = odb_close_file(lck, h, &delete_path);
 		if (!NT_STATUS_IS_OK(status)) {
 			DEBUG(0,("Unable to remove opendb entry for '%s' - %s\n", 
 				 h->name->full_name, nt_errstr(status)));
 		}
 
+		if (h->name->stream_name == NULL &&
+		    h->open_completed && delete_path) {
+			status = pvfs_xattr_unlink_hook(h->pvfs, delete_path);
+			if (!NT_STATUS_IS_OK(status)) {
+				DEBUG(0,("Warning: xattr unlink hook failed for '%s' - %s\n",
+					 delete_path, nt_errstr(status)));
+			}
+			if (unlink(delete_path) != 0) {
+				DEBUG(0,("pvfs_close: failed to delete '%s' - %s\n",
+					 delete_path, strerror(errno)));
+			} else {
+				notify_trigger(h->pvfs->notify_context,
+					       NOTIFY_ACTION_REMOVED,
+					       FILE_NOTIFY_CHANGE_FILE_NAME,
+					       delete_path);
+			}
+		}
+
 		talloc_free(lck);
 	}
 
@@ -574,7 +560,7 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
 		status = pvfs_locking_key(parent, req, &locking_key);
 		NT_STATUS_NOT_OK_RETURN(status);
 		status = odb_get_delete_on_close(pvfs->odb_context, &locking_key, 
-						 &del_on_close, NULL, NULL);
+						 &del_on_close);
 		NT_STATUS_NOT_OK_RETURN(status);
 		if (del_on_close) {
 			return NT_STATUS_DELETE_PENDING;
@@ -1738,14 +1724,13 @@ NTSTATUS pvfs_can_stat(struct pvfs_state *pvfs,
 /*
   determine if delete on close is set on 
 */
-bool pvfs_delete_on_close_set(struct pvfs_state *pvfs, struct pvfs_file_handle *h, 
-			      int *open_count, char **path)
+bool pvfs_delete_on_close_set(struct pvfs_state *pvfs, struct pvfs_file_handle *h)
 {
 	NTSTATUS status;
 	bool del_on_close;
 
 	status = odb_get_delete_on_close(pvfs->odb_context, &h->odb_locking_key, 
-					 &del_on_close, open_count, path);
+					 &del_on_close);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(1,("WARNING: unable to determine delete on close status for open file\n"));
 		return false;
diff --git a/source/ntvfs/posix/pvfs_qfileinfo.c b/source/ntvfs/posix/pvfs_qfileinfo.c
index 8d23d70..6ed7295 100644
--- a/source/ntvfs/posix/pvfs_qfileinfo.c
+++ b/source/ntvfs/posix/pvfs_qfileinfo.c
@@ -380,7 +380,7 @@ NTSTATUS pvfs_qfileinfo(struct ntvfs_module_context *ntvfs,
 	switch (info->generic.level) {
 	case RAW_FILEINFO_STANDARD_INFO:
 	case RAW_FILEINFO_STANDARD_INFORMATION:
-		if (pvfs_delete_on_close_set(pvfs, h, NULL, NULL)) {
+		if (pvfs_delete_on_close_set(pvfs, h)) {
 			info->standard_info.out.delete_pending = 1;
 			info->standard_info.out.nlink--;
 		}
@@ -388,7 +388,7 @@ NTSTATUS pvfs_qfileinfo(struct ntvfs_module_context *ntvfs,
 
 	case RAW_FILEINFO_ALL_INFO:
 	case RAW_FILEINFO_ALL_INFORMATION:
-		if (pvfs_delete_on_close_set(pvfs, h, NULL, NULL)) {
+		if (pvfs_delete_on_close_set(pvfs, h)) {
 			info->all_info.out.delete_pending = 1;
 			info->all_info.out.nlink--;
 		}
@@ -407,7 +407,7 @@ NTSTATUS pvfs_qfileinfo(struct ntvfs_module_context *ntvfs,
 		break;
 
 	case RAW_FILEINFO_SMB2_ALL_INFORMATION:
-		if (pvfs_delete_on_close_set(pvfs, h, NULL, NULL)) {
+		if (pvfs_delete_on_close_set(pvfs, h)) {
 			info->all_info2.out.delete_pending = 1;
 			info->all_info2.out.nlink--;
 		}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list