Changeset 988 for vendor/current/source4/ntvfs/common
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/source4/ntvfs/common
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/ntvfs/common/brlock.c
r740 r988 27 27 #include "includes.h" 28 28 #include "system/filesys.h" 29 #include <tdb.h>30 29 #include "messaging/messaging.h" 31 30 #include "lib/messaging/irpc.h" … … 39 38 set the brl backend ops 40 39 */ 41 void brl _set_ops(const struct brlock_ops *new_ops)40 void brlock_set_ops(const struct brlock_ops *new_ops) 42 41 { 43 42 ops = new_ops; … … 46 45 /* 47 46 Open up the brlock database. Close it down using talloc_free(). We 48 need the messaging_ctx to allow for pending lock notifications.47 need the imessaging_ctx to allow for pending lock notifications. 49 48 */ 50 struct brl_context *brl _init(TALLOC_CTX *mem_ctx, struct server_id server,49 struct brl_context *brlock_init(TALLOC_CTX *mem_ctx, struct server_id server, 51 50 struct loadparm_context *lp_ctx, 52 struct messaging_context *messaging_ctx)51 struct imessaging_context *imessaging_ctx) 53 52 { 54 53 if (ops == NULL) { 55 54 brl_tdb_init_ops(); 56 55 } 57 return ops->brl_init(mem_ctx, server, lp_ctx, messaging_ctx);56 return ops->brl_init(mem_ctx, server, lp_ctx, imessaging_ctx); 58 57 } 59 58 60 struct brl_handle *brl _create_handle(TALLOC_CTX *mem_ctx, struct ntvfs_handle *ntvfs, DATA_BLOB *file_key)59 struct brl_handle *brlock_create_handle(TALLOC_CTX *mem_ctx, struct ntvfs_handle *ntvfs, DATA_BLOB *file_key) 61 60 { 62 61 return ops->brl_create_handle(mem_ctx, ntvfs, file_key); … … 70 69 notification is sent, identified by the notify_ptr 71 70 */ 72 NTSTATUS brl _lock(struct brl_context *brl,71 NTSTATUS brlock_lock(struct brl_context *brl, 73 72 struct brl_handle *brlh, 74 73 uint32_t smbpid, … … 84 83 Unlock a range of bytes. 85 84 */ 86 NTSTATUS brl _unlock(struct brl_context *brl,85 NTSTATUS brlock_unlock(struct brl_context *brl, 87 86 struct brl_handle *brlh, 88 87 uint32_t smbpid, … … 97 96 getting it. In either case they no longer need to be notified. 98 97 */ 99 NTSTATUS brl _remove_pending(struct brl_context *brl,98 NTSTATUS brlock_remove_pending(struct brl_context *brl, 100 99 struct brl_handle *brlh, 101 100 void *notify_ptr) … … 108 107 Test if we are allowed to perform IO on a region of an open file 109 108 */ 110 NTSTATUS brl _locktest(struct brl_context *brl,109 NTSTATUS brlock_locktest(struct brl_context *brl, 111 110 struct brl_handle *brlh, 112 111 uint32_t smbpid, … … 121 120 Remove any locks associated with a open file. 122 121 */ 123 NTSTATUS brl _close(struct brl_context *brl,122 NTSTATUS brlock_close(struct brl_context *brl, 124 123 struct brl_handle *brlh) 125 124 { … … 130 129 Get a number of locks associated with a open file. 131 130 */ 132 NTSTATUS brl _count(struct brl_context *brl,131 NTSTATUS brlock_count(struct brl_context *brl, 133 132 struct brl_handle *brlh, 134 133 int *count) -
vendor/current/source4/ntvfs/common/brlock.h
r740 r988 25 25 struct brl_context *(*brl_init)(TALLOC_CTX *, struct server_id , 26 26 struct loadparm_context *lp_ctx, 27 struct messaging_context *);27 struct imessaging_context *); 28 28 struct brl_handle *(*brl_create_handle)(TALLOC_CTX *, struct ntvfs_handle *, DATA_BLOB *); 29 29 NTSTATUS (*brl_lock)(struct brl_context *, … … 52 52 }; 53 53 54 55 void brl_set_ops(const struct brlock_ops *new_ops); 54 void brlock_set_ops(const struct brlock_ops *new_ops); 56 55 void brl_tdb_init_ops(void); 57 void brl_ctdb_init_ops(void);58 -
vendor/current/source4/ntvfs/common/brlock_tdb.c
r740 r988 27 27 #include "includes.h" 28 28 #include "system/filesys.h" 29 #include <tdb.h>30 29 #include "messaging/messaging.h" 31 #include "lib/util/tdb_wrap.h"32 30 #include "lib/messaging/irpc.h" 33 31 #include "libcli/libcli.h" … … 36 34 #include "ntvfs/ntvfs.h" 37 35 #include "param/param.h" 36 #include "dbwrap/dbwrap.h" 38 37 39 38 /* … … 47 46 /* this struct is typicaly attached to tcon */ 48 47 struct brl_context { 49 struct tdb_wrap *w;48 struct db_context *db; 50 49 struct server_id server; 51 struct messaging_context *messaging_ctx;50 struct imessaging_context *imessaging_ctx; 52 51 }; 53 52 … … 90 89 /* 91 90 Open up the brlock.tdb database. Close it down using 92 talloc_free(). We need the messaging_ctx to allow for91 talloc_free(). We need the imessaging_ctx to allow for 93 92 pending lock notifications. 94 93 */ 95 94 static struct brl_context *brl_tdb_init(TALLOC_CTX *mem_ctx, struct server_id server, 96 95 struct loadparm_context *lp_ctx, 97 struct messaging_context *messaging_ctx)96 struct imessaging_context *imessaging_ctx) 98 97 { 99 98 struct brl_context *brl; … … 104 103 } 105 104 106 brl-> w = cluster_tdb_tmp_open(brl, lp_ctx, "brlock.tdb", TDB_DEFAULT);107 if (brl-> w== NULL) {105 brl->db = cluster_db_tmp_open(brl, lp_ctx, "brlock", TDB_DEFAULT); 106 if (brl->db == NULL) { 108 107 talloc_free(brl); 109 108 return NULL; … … 111 110 112 111 brl->server = server; 113 brl-> messaging_ctx =messaging_ctx;112 brl->imessaging_ctx = imessaging_ctx; 114 113 115 114 return brl; … … 152 151 struct lock_struct *lck2) 153 152 { 154 /* this extra check is not redund ent - it copes with locks153 /* this extra check is not redundant - it copes with locks 155 154 that go beyond the end of 64 bit file space */ 156 155 if (lck1->size != 0 && … … 243 242 244 243 /* in SMB2 mode always return NT_STATUS_LOCK_NOT_GRANTED! */ 245 if (lock->ntvfs->ctx->protocol == PROTOCOL_SMB2) {244 if (lock->ntvfs->ctx->protocol >= PROTOCOL_SMB2_02) { 246 245 return NT_STATUS_LOCK_NOT_GRANTED; 247 246 } … … 303 302 struct lock_struct lock, *locks=NULL; 304 303 NTSTATUS status; 304 struct db_record *locked; 305 305 306 306 kbuf.dptr = brlh->key.data; … … 311 311 } 312 312 313 if (tdb_chainlock(brl->w->tdb, kbuf) != 0) { 313 locked = dbwrap_fetch_locked(brl->db, brl, kbuf); 314 if (!locked) { 314 315 return NT_STATUS_INTERNAL_DB_CORRUPTION; 315 316 } … … 329 330 330 331 if (NT_STATUS_IS_OK(status)) { 331 t db_chainunlock(brl->w->tdb, kbuf);332 talloc_free(locked); 332 333 return NT_STATUS_OK; 333 334 } 334 335 } 335 336 336 dbuf = tdb_fetch(brl->w->tdb, kbuf);337 dbuf = dbwrap_record_get_value(locked); 337 338 338 339 lock.context.smbpid = smbpid; … … 359 360 360 361 /* no conflicts - add it to the list of locks */ 361 locks = realloc_p(locks, struct lock_struct, count+1); 362 /* FIXME: a dbwrap_record_append() would help here! */ 363 locks = talloc_array(locked, struct lock_struct, count+1); 362 364 if (!locks) { 363 365 status = NT_STATUS_NO_MEMORY; 364 366 goto fail; 365 } else { 366 dbuf.dptr = (uint8_t *)locks; 367 } 367 } 368 memcpy(locks, dbuf.dptr, dbuf.dsize); 368 369 locks[count] = lock; 370 371 dbuf.dptr = (unsigned char *)locks; 369 372 dbuf.dsize += sizeof(lock); 370 373 371 if (tdb_store(brl->w->tdb, kbuf, dbuf, TDB_REPLACE) != 0) {372 status = NT_STATUS_INTERNAL_DB_CORRUPTION;374 status = dbwrap_record_store(locked, dbuf, TDB_REPLACE); 375 if (!NT_STATUS_IS_OK(status)) { 373 376 goto fail; 374 377 } 375 378 376 free(dbuf.dptr); 377 tdb_chainunlock(brl->w->tdb, kbuf); 379 talloc_free(locked); 378 380 379 381 /* the caller needs to know if the real lock was granted. If … … 387 389 388 390 fail: 389 390 free(dbuf.dptr); 391 tdb_chainunlock(brl->w->tdb, kbuf); 391 talloc_free(locked); 392 392 return status; 393 393 } … … 420 420 last_notice = i; 421 421 } 422 messaging_send_ptr(brl->messaging_ctx, locks[i].context.server,422 imessaging_send_ptr(brl->imessaging_ctx, locks[i].context.server, 423 423 MSG_BRL_RETRY, locks[i].notify_ptr); 424 424 } … … 456 456 struct lock_struct *locks, *lock; 457 457 struct lock_context context; 458 struct db_record *locked; 458 459 NTSTATUS status; 459 460 … … 465 466 } 466 467 467 if (tdb_chainlock(brl->w->tdb, kbuf) != 0) { 468 locked = dbwrap_fetch_locked(brl->db, brl, kbuf); 469 if (!locked) { 468 470 return NT_STATUS_INTERNAL_DB_CORRUPTION; 469 471 } 470 471 dbuf = tdb_fetch(brl->w->tdb, kbuf); 472 if (!dbuf.dptr) { 473 tdb_chainunlock(brl->w->tdb, kbuf); 474 return NT_STATUS_RANGE_NOT_LOCKED; 475 } 472 dbuf = dbwrap_record_get_value(locked); 476 473 477 474 context.smbpid = smbpid; … … 510 507 /* found it - delete it */ 511 508 if (count == 1) { 512 if (tdb_delete(brl->w->tdb, kbuf) != 0) {513 status = NT_STATUS_INTERNAL_DB_CORRUPTION;509 status = dbwrap_record_delete(locked); 510 if (!NT_STATUS_IS_OK(status)) { 514 511 goto fail; 515 512 } … … 526 523 527 524 dbuf.dsize = count * sizeof(*locks); 528 529 if (tdb_store(brl->w->tdb, kbuf, dbuf, TDB_REPLACE) != 0) {530 status = NT_STATUS_INTERNAL_DB_CORRUPTION;525 526 status = dbwrap_record_store(locked, dbuf, TDB_REPLACE); 527 if (!NT_STATUS_IS_OK(status)) { 531 528 goto fail; 532 529 } 533 530 } 534 535 free(dbuf.dptr); 536 tdb_chainunlock(brl->w->tdb, kbuf); 531 532 talloc_free(locked); 537 533 return NT_STATUS_OK; 538 534 } … … 542 538 543 539 fail: 544 free(dbuf.dptr); 545 tdb_chainunlock(brl->w->tdb, kbuf); 540 talloc_free(locked); 546 541 return status; 547 542 } … … 561 556 struct lock_struct *locks; 562 557 NTSTATUS status; 558 struct db_record *locked; 563 559 564 560 kbuf.dptr = brlh->key.data; 565 561 kbuf.dsize = brlh->key.length; 566 562 567 if (tdb_chainlock(brl->w->tdb, kbuf) != 0) { 563 locked = dbwrap_fetch_locked(brl->db, brl, kbuf); 564 if (!locked) { 568 565 return NT_STATUS_INTERNAL_DB_CORRUPTION; 569 566 } 570 567 571 dbuf = tdb_fetch(brl->w->tdb, kbuf);568 dbuf = dbwrap_record_get_value(locked); 572 569 if (!dbuf.dptr) { 573 t db_chainunlock(brl->w->tdb, kbuf);570 talloc_free(locked); 574 571 return NT_STATUS_RANGE_NOT_LOCKED; 575 572 } … … 587 584 /* found it - delete it */ 588 585 if (count == 1) { 589 if (tdb_delete(brl->w->tdb, kbuf) != 0) {590 status = NT_STATUS_INTERNAL_DB_CORRUPTION;586 status = dbwrap_record_delete(locked); 587 if (!NT_STATUS_IS_OK(status)) { 591 588 goto fail; 592 589 } … … 598 595 count--; 599 596 dbuf.dsize = count * sizeof(*locks); 600 if (tdb_store(brl->w->tdb, kbuf, dbuf, TDB_REPLACE) != 0) { 601 status = NT_STATUS_INTERNAL_DB_CORRUPTION; 597 status = dbwrap_record_store(locked, dbuf, 598 TDB_REPLACE); 599 if (!NT_STATUS_IS_OK(status)) { 602 600 goto fail; 603 601 } 604 602 } 605 603 606 free(dbuf.dptr); 607 tdb_chainunlock(brl->w->tdb, kbuf); 604 talloc_free(locked); 608 605 return NT_STATUS_OK; 609 606 } … … 614 611 615 612 fail: 616 free(dbuf.dptr); 617 tdb_chainunlock(brl->w->tdb, kbuf); 613 talloc_free(locked); 618 614 return status; 619 615 } … … 632 628 int count, i; 633 629 struct lock_struct lock, *locks; 630 NTSTATUS status; 634 631 635 632 kbuf.dptr = brlh->key.data; … … 640 637 } 641 638 642 dbuf = tdb_fetch(brl->w->tdb, kbuf);643 if ( dbuf.dptr == NULL) {639 status = dbwrap_fetch(brl->db, brl, kbuf, &dbuf); 640 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { 644 641 return NT_STATUS_OK; 642 } else if (!NT_STATUS_IS_OK(status)) { 643 return status; 645 644 } 646 645 … … 659 658 for (i=0; i<count; i++) { 660 659 if (brl_tdb_conflict_other(&locks[i], &lock)) { 661 free(dbuf.dptr);660 talloc_free(dbuf.dptr); 662 661 return NT_STATUS_FILE_LOCK_CONFLICT; 663 662 } 664 663 } 665 664 666 free(dbuf.dptr);665 talloc_free(dbuf.dptr); 667 666 return NT_STATUS_OK; 668 667 } … … 678 677 int count, i, dcount=0; 679 678 struct lock_struct *locks; 679 struct db_record *locked; 680 680 NTSTATUS status; 681 681 … … 683 683 kbuf.dsize = brlh->key.length; 684 684 685 if (tdb_chainlock(brl->w->tdb, kbuf) != 0) { 685 locked = dbwrap_fetch_locked(brl->db, brl, kbuf); 686 if (!locked) { 686 687 return NT_STATUS_INTERNAL_DB_CORRUPTION; 687 688 } 688 689 dbuf = tdb_fetch(brl->w->tdb, kbuf); 689 dbuf = dbwrap_record_get_value(locked); 690 690 if (!dbuf.dptr) { 691 t db_chainunlock(brl->w->tdb, kbuf);691 talloc_free(locked); 692 692 return NT_STATUS_OK; 693 693 } … … 717 717 718 718 if (count == 0) { 719 if (tdb_delete(brl->w->tdb, kbuf) != 0) { 720 status = NT_STATUS_INTERNAL_DB_CORRUPTION; 721 } 719 status = dbwrap_record_delete(locked); 722 720 } else if (dcount != 0) { 723 721 /* tell all pending lock holders for this file that … … 728 726 dbuf.dsize = count * sizeof(*locks); 729 727 730 if (tdb_store(brl->w->tdb, kbuf, dbuf, TDB_REPLACE) != 0) { 731 status = NT_STATUS_INTERNAL_DB_CORRUPTION; 732 } 733 } 734 735 free(dbuf.dptr); 736 tdb_chainunlock(brl->w->tdb, kbuf); 728 status = dbwrap_record_store(locked, dbuf, TDB_REPLACE); 729 } 730 talloc_free(locked); 737 731 738 732 return status; … … 743 737 { 744 738 TDB_DATA kbuf, dbuf; 739 NTSTATUS status; 745 740 746 741 kbuf.dptr = brlh->key.data; … … 748 743 *count = 0; 749 744 750 if (tdb_chainlock(brl->w->tdb, kbuf) != 0) { 751 return NT_STATUS_INTERNAL_DB_CORRUPTION; 752 } 753 754 dbuf = tdb_fetch(brl->w->tdb, kbuf); 755 if (!dbuf.dptr) { 756 tdb_chainunlock(brl->w->tdb, kbuf); 745 status = dbwrap_fetch(brl->db, brl, kbuf, &dbuf); 746 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { 757 747 return NT_STATUS_OK; 758 } 759 748 } else if (!NT_STATUS_IS_OK(status)) { 749 return status; 750 } 760 751 *count = dbuf.dsize / sizeof(struct lock_struct); 761 752 762 free(dbuf.dptr); 763 tdb_chainunlock(brl->w->tdb, kbuf); 753 talloc_free(dbuf.dptr); 764 754 765 755 return NT_STATUS_OK; … … 780 770 void brl_tdb_init_ops(void) 781 771 { 782 brl _set_ops(&brlock_tdb_ops);783 } 772 brlock_set_ops(&brlock_tdb_ops); 773 } -
vendor/current/source4/ntvfs/common/init.c
r414 r988 27 27 #include "ntvfs/sysdep/sys_notify.h" 28 28 29 NTSTATUS ntvfs_common_init(void); 30 29 31 NTSTATUS ntvfs_common_init(void) 30 32 { -
vendor/current/source4/ntvfs/common/notify.c
r740 r988 26 26 #include "includes.h" 27 27 #include "system/filesys.h" 28 #include <tdb.h>29 #include "../lib/util/util_tdb.h"30 28 #include "messaging/messaging.h" 31 #include "lib/util/tdb_wrap.h"32 29 #include "lib/messaging/irpc.h" 33 #include "librpc/gen_ndr/ndr_ s4_notify.h"30 #include "librpc/gen_ndr/ndr_notify.h" 34 31 #include "../lib/util/dlinklist.h" 35 32 #include "ntvfs/common/ntvfs_common.h" … … 38 35 #include "param/param.h" 39 36 #include "lib/util/tsort.h" 37 #include "lib/dbwrap/dbwrap.h" 38 #include "../lib/util/util_tdb.h" 40 39 41 40 struct notify_context { 42 struct tdb_wrap *w;41 struct db_context *db; 43 42 struct server_id server; 44 struct messaging_context *messaging_ctx;43 struct imessaging_context *imessaging_ctx; 45 44 struct notify_list *list; 46 45 struct notify_array *array; 47 int seqnum;46 int64_t seqnum; 48 47 struct sys_notify_context *sys_notify_ctx; 49 48 }; … … 64 63 65 64 static NTSTATUS notify_remove_all(struct notify_context *notify); 66 static void notify_handler(struct messaging_context *msg_ctx, void *private_data,65 static void notify_handler(struct imessaging_context *msg_ctx, void *private_data, 67 66 uint32_t msg_type, struct server_id server_id, DATA_BLOB *data); 68 67 … … 72 71 static int notify_destructor(struct notify_context *notify) 73 72 { 74 messaging_deregister(notify->messaging_ctx, MSG_PVFS_NOTIFY, notify);73 imessaging_deregister(notify->imessaging_ctx, MSG_PVFS_NOTIFY, notify); 75 74 notify_remove_all(notify); 76 75 return 0; … … 79 78 /* 80 79 Open up the notify.tdb database. You should close it down using 81 talloc_free(). We need the messaging_ctx to allow for notifications80 talloc_free(). We need the imessaging_ctx to allow for notifications 82 81 via internal messages 83 82 */ 84 83 struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, 85 struct messaging_context *messaging_ctx,84 struct imessaging_context *imessaging_ctx, 86 85 struct loadparm_context *lp_ctx, 87 86 struct tevent_context *ev, … … 103 102 } 104 103 105 notify-> w = cluster_tdb_tmp_open(notify, lp_ctx, "notify.tdb", TDB_SEQNUM);106 if (notify-> w== NULL) {104 notify->db = cluster_db_tmp_open(notify, lp_ctx, "notify", TDB_SEQNUM); 105 if (notify->db == NULL) { 107 106 talloc_free(notify); 108 107 return NULL; … … 110 109 111 110 notify->server = server; 112 notify-> messaging_ctx =messaging_ctx;111 notify->imessaging_ctx = imessaging_ctx; 113 112 notify->list = NULL; 114 113 notify->array = NULL; 115 notify->seqnum = tdb_get_seqnum(notify->w->tdb);114 notify->seqnum = dbwrap_get_seqnum(notify->db); 116 115 117 116 talloc_set_destructor(notify, notify_destructor); … … 119 118 /* register with the messaging subsystem for the notify 120 119 message type */ 121 messaging_register(notify->messaging_ctx, notify,120 imessaging_register(notify->imessaging_ctx, notify, 122 121 MSG_PVFS_NOTIFY, notify_handler); 123 122 … … 131 130 lock the notify db 132 131 */ 133 static NTSTATUS notify_lock(struct notify_context *notify) 134 { 135 if (tdb_lock_bystring(notify->w->tdb, NOTIFY_KEY) != 0) { 136 return NT_STATUS_INTERNAL_DB_CORRUPTION; 137 } 138 return NT_STATUS_OK; 139 } 140 141 /* 142 unlock the notify db 143 */ 144 static void notify_unlock(struct notify_context *notify) 145 { 146 tdb_unlock_bystring(notify->w->tdb, NOTIFY_KEY); 132 static struct db_record *notify_lock(struct notify_context *notify) 133 { 134 TDB_DATA key = string_term_tdb_data(NOTIFY_KEY); 135 136 return dbwrap_fetch_locked(notify->db, notify, key); 137 } 138 139 static void notify_unlock(struct db_record *lock) 140 { 141 talloc_free(lock); 147 142 } 148 143 … … 156 151 enum ndr_err_code ndr_err; 157 152 int seqnum; 158 159 seqnum = tdb_get_seqnum(notify->w->tdb); 153 NTSTATUS status; 154 155 seqnum = dbwrap_get_seqnum(notify->db); 160 156 161 157 if (seqnum == notify->seqnum && notify->array != NULL) { … … 169 165 NT_STATUS_HAVE_NO_MEMORY(notify->array); 170 166 171 dbuf = tdb_fetch_bystring(notify->w->tdb, NOTIFY_KEY);172 if ( dbuf.dptr == NULL) {167 status = dbwrap_fetch_bystring(notify->db, notify, NOTIFY_KEY, &dbuf); 168 if (!NT_STATUS_IS_OK(status)) { 173 169 return NT_STATUS_OK; 174 170 } … … 179 175 ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->array, 180 176 (ndr_pull_flags_fn_t)ndr_pull_notify_array); 181 free(dbuf.dptr);177 talloc_free(dbuf.dptr); 182 178 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 183 179 return ndr_map_error2ntstatus(ndr_err); … … 204 200 DATA_BLOB blob; 205 201 enum ndr_err_code ndr_err; 206 int ret;207 202 TALLOC_CTX *tmp_ctx; 203 NTSTATUS status; 208 204 209 205 /* if possible, remove some depth arrays */ … … 215 211 /* we might just be able to delete the record */ 216 212 if (notify->array->num_depths == 0) { 217 ret = tdb_delete_bystring(notify->w->tdb, NOTIFY_KEY); 218 if (ret != 0) { 219 return NT_STATUS_INTERNAL_DB_CORRUPTION; 220 } 221 return NT_STATUS_OK; 213 return dbwrap_delete_bystring(notify->db, NOTIFY_KEY); 222 214 } 223 215 … … 234 226 dbuf.dptr = blob.data; 235 227 dbuf.dsize = blob.length; 236 237 ret = tdb_store_bystring(notify->w->tdb, NOTIFY_KEY, dbuf, TDB_REPLACE); 228 229 status = dbwrap_store_bystring(notify->db, NOTIFY_KEY, dbuf, 230 TDB_REPLACE); 238 231 talloc_free(tmp_ctx); 239 if (ret != 0) { 240 return NT_STATUS_INTERNAL_DB_CORRUPTION; 241 } 242 243 return NT_STATUS_OK; 232 return status; 244 233 } 245 234 … … 248 237 handle incoming notify messages 249 238 */ 250 static void notify_handler(struct messaging_context *msg_ctx, void *private_data,239 static void notify_handler(struct imessaging_context *msg_ctx, void *private_data, 251 240 uint32_t msg_type, struct server_id server_id, DATA_BLOB *data) 252 241 { … … 355 344 size_t len; 356 345 int depth; 346 struct db_record *locked; 357 347 358 348 /* see if change notify is enabled at all */ … … 361 351 } 362 352 363 status = notify_lock(notify); 364 NT_STATUS_NOT_OK_RETURN(status); 353 locked = notify_lock(notify); 354 if (!locked) { 355 return NT_STATUS_INTERNAL_DB_CORRUPTION; 356 } 365 357 366 358 status = notify_load(notify); … … 416 408 417 409 done: 418 notify_unlock( notify);410 notify_unlock(locked); 419 411 talloc_free(tmp_path); 420 412 … … 431 423 int i, depth; 432 424 struct notify_depth *d; 425 struct db_record *locked; 433 426 434 427 /* see if change notify is enabled at all */ … … 451 444 talloc_free(listel); 452 445 453 status = notify_lock(notify); 454 NT_STATUS_NOT_OK_RETURN(status); 446 locked = notify_lock(notify); 447 if (!locked) { 448 return NT_STATUS_INTERNAL_DB_CORRUPTION; 449 } 455 450 456 451 status = notify_load(notify); 457 452 if (!NT_STATUS_IS_OK(status)) { 458 notify_unlock( notify);453 notify_unlock(locked); 459 454 return status; 460 455 } 461 456 462 457 if (depth >= notify->array->num_depths) { 463 notify_unlock( notify);458 notify_unlock(locked); 464 459 return NT_STATUS_OBJECT_NAME_NOT_FOUND; 465 460 } … … 475 470 } 476 471 if (i == d->num_entries) { 477 notify_unlock( notify);472 notify_unlock(locked); 478 473 return NT_STATUS_OBJECT_NAME_NOT_FOUND; 479 474 } … … 487 482 status = notify_save(notify); 488 483 489 notify_unlock( notify);484 notify_unlock(locked); 490 485 491 486 return status; … … 499 494 NTSTATUS status; 500 495 int i, depth, del_count=0; 496 struct db_record *locked; 501 497 502 498 if (notify->list == NULL) { … … 504 500 } 505 501 506 status = notify_lock(notify); 507 NT_STATUS_NOT_OK_RETURN(status); 502 locked = notify_lock(notify); 503 if (!locked) { 504 return NT_STATUS_INTERNAL_DB_CORRUPTION; 505 } 508 506 509 507 status = notify_load(notify); 510 508 if (!NT_STATUS_IS_OK(status)) { 511 notify_unlock( notify);509 notify_unlock(locked); 512 510 return status; 513 511 } … … 534 532 } 535 533 536 notify_unlock( notify);534 notify_unlock(locked); 537 535 538 536 return status; … … 553 551 554 552 ev.action = action; 553 ev.dir = discard_const_p(char, ""); 555 554 ev.path = path; 556 555 ev.private_data = e->private_data; … … 564 563 } 565 564 566 status = messaging_send(notify->messaging_ctx, e->server,565 status = imessaging_send(notify->imessaging_ctx, e->server, 567 566 MSG_PVFS_NOTIFY, &data); 567 if (!NT_STATUS_IS_OK(status)) { 568 talloc_free(tmp_ctx); 569 return; 570 } 571 568 572 talloc_free(tmp_ctx); 569 573 } -
vendor/current/source4/ntvfs/common/opendb.c
r414 r988 56 56 /* 57 57 Open up the openfiles.tdb database. Close it down using 58 talloc_free(). We need the messaging_ctx to allow for pending open58 talloc_free(). We need the imessaging_ctx to allow for pending open 59 59 notifications. 60 60 */ -
vendor/current/source4/ntvfs/common/opendb.h
r414 r988 58 58 void odb_set_ops(const struct opendb_ops *new_ops); 59 59 void odb_tdb_init_ops(void); 60 void odb_ctdb_init_ops(void); -
vendor/current/source4/ntvfs/common/opendb_tdb.c
r740 r988 41 41 #include "includes.h" 42 42 #include "system/filesys.h" 43 #include <tdb.h>43 #include "lib/dbwrap/dbwrap.h" 44 44 #include "messaging/messaging.h" 45 #include "lib/util/tdb_wrap.h"46 45 #include "lib/messaging/irpc.h" 47 46 #include "librpc/gen_ndr/ndr_opendb.h" … … 53 52 54 53 struct odb_context { 55 struct tdb_wrap *w;54 struct db_context *db; 56 55 struct ntvfs_context *ntvfs_ctx; 57 56 bool oplocks; … … 65 64 struct odb_lock { 66 65 struct odb_context *odb; 67 TDB_DATA key;66 struct db_record *locked; 68 67 69 68 struct opendb_file file; … … 75 74 }; 76 75 77 static NTSTATUS odb_oplock_break_send(struct messaging_context *msg_ctx,76 static NTSTATUS odb_oplock_break_send(struct imessaging_context *msg_ctx, 78 77 struct opendb_entry *e, 79 78 uint8_t level); … … 81 80 /* 82 81 Open up the openfiles.tdb database. Close it down using 83 talloc_free(). We need the messaging_ctx to allow for pending open82 talloc_free(). We need the imessaging_ctx to allow for pending open 84 83 notifications. 85 84 */ … … 94 93 } 95 94 96 odb->w = cluster_tdb_tmp_open(odb, ntvfs_ctx->lp_ctx, "openfiles.tdb", TDB_DEFAULT); 97 if (odb->w == NULL) { 95 odb->db = cluster_db_tmp_open(odb, ntvfs_ctx->lp_ctx, 96 "openfiles", TDB_DEFAULT); 97 if (odb->db == NULL) { 98 98 talloc_free(odb); 99 99 return NULL; … … 112 112 } 113 113 114 /*115 destroy a lock on the database116 */117 static int odb_lock_destructor(struct odb_lock *lck)118 {119 tdb_chainunlock(lck->odb->w->tdb, lck->key);120 return 0;121 }122 123 114 static NTSTATUS odb_pull_record(struct odb_lock *lck, struct opendb_file *file); 124 115 … … 132 123 struct odb_lock *lck; 133 124 NTSTATUS status; 125 TDB_DATA key; 134 126 135 127 lck = talloc(mem_ctx, struct odb_lock); … … 139 131 140 132 lck->odb = talloc_reference(lck, odb); 141 lck->key.dptr = talloc_memdup(lck, file_key->data, file_key->length);142 lck->key.dsize = file_key->length;143 if ( lck->key.dptr == NULL) {133 key.dptr = talloc_memdup(lck, file_key->data, file_key->length); 134 key.dsize = file_key->length; 135 if (key.dptr == NULL) { 144 136 talloc_free(lck); 145 137 return NULL; 146 138 } 147 139 148 if (tdb_chainlock(odb->w->tdb, lck->key) != 0) { 140 lck->locked = dbwrap_fetch_locked(odb->db, lck, key); 141 if (!lck->locked) { 149 142 talloc_free(lck); 150 143 return NULL; … … 152 145 153 146 ZERO_STRUCT(lck->can_open); 154 155 talloc_set_destructor(lck, odb_lock_destructor);156 147 157 148 status = odb_pull_record(lck, &lck->file); … … 169 160 static DATA_BLOB odb_tdb_get_key(TALLOC_CTX *mem_ctx, struct odb_lock *lck) 170 161 { 171 return data_blob_talloc(mem_ctx, lck->key.dptr, lck->key.dsize); 162 TDB_DATA key = dbwrap_record_get_key(lck->locked); 163 return data_blob_talloc(mem_ctx, key.dptr, key.dsize); 172 164 } 173 165 … … 234 226 static NTSTATUS odb_pull_record(struct odb_lock *lck, struct opendb_file *file) 235 227 { 236 struct odb_context *odb = lck->odb;237 228 TDB_DATA dbuf; 238 229 DATA_BLOB blob; 239 230 enum ndr_err_code ndr_err; 240 231 241 dbuf = tdb_fetch(odb->w->tdb, lck->key);242 if ( dbuf.dptr == NULL) {232 dbuf = dbwrap_record_get_value(lck->locked); 233 if (!dbuf.dptr) { 243 234 return NT_STATUS_OBJECT_NAME_NOT_FOUND; 244 235 } … … 248 239 249 240 ndr_err = ndr_pull_struct_blob(&blob, lck, file, (ndr_pull_flags_fn_t)ndr_pull_opendb_file); 250 free(dbuf.dptr);251 241 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 252 242 return ndr_map_error2ntstatus(ndr_err); … … 261 251 static NTSTATUS odb_push_record(struct odb_lock *lck, struct opendb_file *file) 262 252 { 263 struct odb_context *odb = lck->odb;264 253 TDB_DATA dbuf; 265 254 DATA_BLOB blob; 266 255 enum ndr_err_code ndr_err; 267 int ret;256 NTSTATUS status; 268 257 269 258 if (file->num_entries == 0) { 270 ret = tdb_delete(odb->w->tdb, lck->key); 271 if (ret != 0) { 272 return NT_STATUS_INTERNAL_DB_CORRUPTION; 273 } 274 return NT_STATUS_OK; 259 return dbwrap_record_delete(lck->locked); 275 260 } 276 261 … … 283 268 dbuf.dsize = blob.length; 284 269 285 ret = tdb_store(odb->w->tdb, lck->key, dbuf, TDB_REPLACE);270 status = dbwrap_record_store(lck->locked, dbuf, TDB_REPLACE); 286 271 data_blob_free(&blob); 287 if (ret != 0) { 288 return NT_STATUS_INTERNAL_DB_CORRUPTION; 289 } 290 291 return NT_STATUS_OK; 272 return status; 292 273 } 293 274 … … 295 276 send an oplock break to a client 296 277 */ 297 static NTSTATUS odb_oplock_break_send(struct messaging_context *msg_ctx,278 static NTSTATUS odb_oplock_break_send(struct imessaging_context *msg_ctx, 298 279 struct opendb_entry *e, 299 280 uint8_t level) … … 312 293 blob = data_blob_const(&op_break, sizeof(op_break)); 313 294 314 status = messaging_send(msg_ctx, e->server,295 status = imessaging_send(msg_ctx, e->server, 315 296 MSG_NTVFS_OPLOCK_BREAK, &blob); 316 297 NT_STATUS_NOT_OK_RETURN(status); … … 612 593 /* send any pending notifications, removing them once sent */ 613 594 for (i=0;i<lck->file.num_pending;i++) { 614 messaging_send_ptr(odb->ntvfs_ctx->msg_ctx,595 imessaging_send_ptr(odb->ntvfs_ctx->msg_ctx, 615 596 lck->file.pending[i].server, 616 597 MSG_PVFS_RETRY_OPEN, … … 667 648 /* send any pending notifications, removing them once sent */ 668 649 for (i=0;i<lck->file.num_pending;i++) { 669 messaging_send_ptr(odb->ntvfs_ctx->msg_ctx,650 imessaging_send_ptr(odb->ntvfs_ctx->msg_ctx, 670 651 lck->file.pending[i].server, 671 652 MSG_PVFS_RETRY_OPEN, -
vendor/current/source4/ntvfs/common/wscript_build
r740 r988 4 4 source='init.c brlock.c brlock_tdb.c opendb.c opendb_tdb.c notify.c', 5 5 autoproto='proto.h', 6 deps='util_tdb tdb-wrap', 6 7 public_deps='NDR_OPENDB NDR_NOTIFY sys_notify sys_lease share' 7 8 )
Note:
See TracChangeset
for help on using the changeset viewer.