The branch, v4-0-test has been updated
       via  daab9cb11eb540fae7ec3c024a586f5fd02cfc71 (commit)
       via  e585e2306334bd919f567f53d8d08903dfdfb102 (commit)
      from  3b70331536d2402814db13a9f1f226a39373313a (commit)

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


- Log -----------------------------------------------------------------
commit daab9cb11eb540fae7ec3c024a586f5fd02cfc71
Author: Stefan Metzmacher <[EMAIL PROTECTED]>
Date:   Thu Feb 21 20:01:25 2008 +0100

    pvfs: handle SHARING_VIOLATION and OPLOCK_NOT_GRANTED in 
pvfs_can_delete/rename()
    
    If the caller asks for the odb_lock return it
    also if we return NT_STATUS_SHARING_VIOLATION
    or NT_STATUS_OPLOCK_NOT_GRANTED so that the caller
    can add the pending notification.
    
    metze

commit e585e2306334bd919f567f53d8d08903dfdfb102
Author: Stefan Metzmacher <[EMAIL PROTECTED]>
Date:   Thu Feb 21 19:59:13 2008 +0100

    pvfs: pass NULL to pvfs_can_*() when no odb_lock is needed by the caller
    
    metze

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

Summary of changes:
 source/ntvfs/posix/pvfs_open.c        |   28 ++++++++++++++++++++++++++--
 source/ntvfs/posix/pvfs_rename.c      |   11 ++++++-----
 source/ntvfs/posix/pvfs_setfileinfo.c |    4 +---
 source/ntvfs/posix/pvfs_unlink.c      |    6 ++----
 4 files changed, 35 insertions(+), 14 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/ntvfs/posix/pvfs_open.c b/source/ntvfs/posix/pvfs_open.c
index 3ccd239..0d97b3d 100644
--- a/source/ntvfs/posix/pvfs_open.c
+++ b/source/ntvfs/posix/pvfs_open.c
@@ -1447,7 +1447,19 @@ NTSTATUS pvfs_can_delete(struct pvfs_state *pvfs,
                status = pvfs_access_check_simple(pvfs, req, name, 
SEC_STD_DELETE);
        }
 
-       if (!NT_STATUS_IS_OK(status)) {
+       /*
+        * if it's a sharing violation or we got no oplock
+        * only keep the lock if the caller requested access
+        * to the lock
+        */
+       if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_OPLOCK_NOT_GRANTED)) {
+               if (lckp) {
+                       *lckp = lck;
+               } else {
+                       talloc_free(lck);
+               }
+       } else if (!NT_STATUS_IS_OK(status)) {
                talloc_free(lck);
                *lckp = lck;
        } else if (lckp != NULL) {
@@ -1487,7 +1499,19 @@ NTSTATUS pvfs_can_rename(struct pvfs_state *pvfs,
                              0,
                              SEC_STD_DELETE);
 
-       if (!NT_STATUS_IS_OK(status)) {
+       /*
+        * if it's a sharing violation or we got no oplock
+        * only keep the lock if the caller requested access
+        * to the lock
+        */
+       if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_OPLOCK_NOT_GRANTED)) {
+               if (lckp) {
+                       *lckp = lck;
+               } else {
+                       talloc_free(lck);
+               }
+       } else if (!NT_STATUS_IS_OK(status)) {
                talloc_free(lck);
                *lckp = lck;
        } else if (lckp != NULL) {
diff --git a/source/ntvfs/posix/pvfs_rename.c b/source/ntvfs/posix/pvfs_rename.c
index ea12f49..5693e79 100644
--- a/source/ntvfs/posix/pvfs_rename.c
+++ b/source/ntvfs/posix/pvfs_rename.c
@@ -192,8 +192,8 @@ static NTSTATUS pvfs_rename_one(struct pvfs_state *pvfs,
 {
        struct pvfs_filename *name1, *name2;
        TALLOC_CTX *mem_ctx = talloc_new(req);
+       struct odb_lock *lck = NULL;
        NTSTATUS status;
-       struct odb_lock *lck, *lck2;
 
        /* resolve the wildcard pattern for this name */
        fname2 = pvfs_resolve_wildcard(mem_ctx, fname1, fname2);
@@ -216,6 +216,7 @@ static NTSTATUS pvfs_rename_one(struct pvfs_state *pvfs,
 
        status = pvfs_can_rename(pvfs, req, name1, &lck);
        if (!NT_STATUS_IS_OK(status)) {
+               talloc_free(lck);
                goto failed;
        }
 
@@ -223,7 +224,7 @@ static NTSTATUS pvfs_rename_one(struct pvfs_state *pvfs,
        status = pvfs_resolve_partial(pvfs, mem_ctx, 
                                      dir_path, fname2, &name2);
        if (NT_STATUS_IS_OK(status)) {
-               status = pvfs_can_delete(pvfs, req, name2, &lck2);
+               status = pvfs_can_delete(pvfs, req, name2, NULL);
                if (!NT_STATUS_IS_OK(status)) {
                        goto failed;
                }
@@ -311,7 +312,7 @@ static NTSTATUS pvfs_rename_mv(struct ntvfs_module_context 
*ntvfs,
        struct pvfs_state *pvfs = ntvfs->private_data;
        NTSTATUS status;
        struct pvfs_filename *name1, *name2;
-       struct odb_lock *lck;
+       struct odb_lock *lck = NULL;
 
        /* resolve the cifs name to a posix name */
        status = pvfs_resolve_name(pvfs, req, ren->rename.in.pattern1, 
@@ -354,6 +355,7 @@ static NTSTATUS pvfs_rename_mv(struct ntvfs_module_context 
*ntvfs,
 
        status = pvfs_can_rename(pvfs, req, name1, &lck);
        if (!NT_STATUS_IS_OK(status)) {
+               talloc_free(lck);
                return status;
        }
 
@@ -375,7 +377,6 @@ static NTSTATUS pvfs_rename_nt(struct ntvfs_module_context 
*ntvfs,
        struct pvfs_state *pvfs = ntvfs->private_data;
        NTSTATUS status;
        struct pvfs_filename *name1, *name2;
-       struct odb_lock *lck;
 
        switch (ren->ntrename.in.flags) {
        case RENAME_FLAG_RENAME:
@@ -421,7 +422,7 @@ static NTSTATUS pvfs_rename_nt(struct ntvfs_module_context 
*ntvfs,
                return status;
        }
 
-       status = pvfs_can_rename(pvfs, req, name1, &lck);
+       status = pvfs_can_rename(pvfs, req, name1, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
diff --git a/source/ntvfs/posix/pvfs_setfileinfo.c 
b/source/ntvfs/posix/pvfs_setfileinfo.c
index 9c78699..fbbb8c2 100644
--- a/source/ntvfs/posix/pvfs_setfileinfo.c
+++ b/source/ntvfs/posix/pvfs_setfileinfo.c
@@ -142,8 +142,6 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state 
*pvfs,
 
        /* if the destination exists, then check the rename is allowed */
        if (name2->exists) {
-               struct odb_lock *lck;
-
                if (strcmp(name2->full_name, name->full_name) == 0) {
                        /* rename to same name is null-op */
                        return NT_STATUS_OK;
@@ -153,7 +151,7 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state 
*pvfs,
                        return NT_STATUS_OBJECT_NAME_COLLISION;
                }
 
-               status = pvfs_can_delete(pvfs, req, name2, &lck);
+               status = pvfs_can_delete(pvfs, req, name2, NULL);
                if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
                        return NT_STATUS_ACCESS_DENIED;
                }
diff --git a/source/ntvfs/posix/pvfs_unlink.c b/source/ntvfs/posix/pvfs_unlink.c
index ef56d99..d6e60b5 100644
--- a/source/ntvfs/posix/pvfs_unlink.c
+++ b/source/ntvfs/posix/pvfs_unlink.c
@@ -33,7 +33,6 @@ static NTSTATUS pvfs_unlink_stream(struct pvfs_state *pvfs,
                                   uint16_t attrib)
 {
        NTSTATUS status;
-       struct odb_lock *lck;
 
        if (!name->stream_exists) {
                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
@@ -45,7 +44,7 @@ static NTSTATUS pvfs_unlink_stream(struct pvfs_state *pvfs,
                return status;
        }
 
-       status = pvfs_can_delete(pvfs, req, name, &lck);
+       status = pvfs_can_delete(pvfs, req, name, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -64,7 +63,6 @@ static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs,
 {
        struct pvfs_filename *name;
        NTSTATUS status;
-       struct odb_lock *lck;
 
        /* get a pvfs_filename object */
        status = pvfs_resolve_partial(pvfs, req, 
@@ -80,7 +78,7 @@ static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs,
                return status;
        }
 
-       status = pvfs_can_delete(pvfs, req, name, &lck);
+       status = pvfs_can_delete(pvfs, req, name, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                talloc_free(name);
                return status;


-- 
Samba Shared Repository

Reply via email to