Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/source4/ntvfs/common
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source4/ntvfs/common/brlock.c

    r740 r988  
    2727#include "includes.h"
    2828#include "system/filesys.h"
    29 #include <tdb.h>
    3029#include "messaging/messaging.h"
    3130#include "lib/messaging/irpc.h"
     
    3938  set the brl backend ops
    4039*/
    41 void brl_set_ops(const struct brlock_ops *new_ops)
     40void brlock_set_ops(const struct brlock_ops *new_ops)
    4241{
    4342        ops = new_ops;
     
    4645/*
    4746  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.
    4948*/
    50 struct brl_context *brl_init(TALLOC_CTX *mem_ctx, struct server_id server,
     49struct brl_context *brlock_init(TALLOC_CTX *mem_ctx, struct server_id server,
    5150                             struct loadparm_context *lp_ctx,
    52                              struct messaging_context *messaging_ctx)
     51                             struct imessaging_context *imessaging_ctx)
    5352{
    5453        if (ops == NULL) {
    5554                brl_tdb_init_ops();
    5655        }
    57         return ops->brl_init(mem_ctx, server, lp_ctx, messaging_ctx);
     56        return ops->brl_init(mem_ctx, server, lp_ctx, imessaging_ctx);
    5857}
    5958
    60 struct brl_handle *brl_create_handle(TALLOC_CTX *mem_ctx, struct ntvfs_handle *ntvfs, DATA_BLOB *file_key)
     59struct brl_handle *brlock_create_handle(TALLOC_CTX *mem_ctx, struct ntvfs_handle *ntvfs, DATA_BLOB *file_key)
    6160{
    6261        return ops->brl_create_handle(mem_ctx, ntvfs, file_key);
     
    7069  notification is sent, identified by the notify_ptr
    7170*/
    72 NTSTATUS brl_lock(struct brl_context *brl,
     71NTSTATUS brlock_lock(struct brl_context *brl,
    7372                  struct brl_handle *brlh,
    7473                  uint32_t smbpid,
     
    8483 Unlock a range of bytes.
    8584*/
    86 NTSTATUS brl_unlock(struct brl_context *brl,
     85NTSTATUS brlock_unlock(struct brl_context *brl,
    8786                    struct brl_handle *brlh,
    8887                    uint32_t smbpid,
     
    9796  getting it. In either case they no longer need to be notified.
    9897*/
    99 NTSTATUS brl_remove_pending(struct brl_context *brl,
     98NTSTATUS brlock_remove_pending(struct brl_context *brl,
    10099                            struct brl_handle *brlh,
    101100                            void *notify_ptr)
     
    108107  Test if we are allowed to perform IO on a region of an open file
    109108*/
    110 NTSTATUS brl_locktest(struct brl_context *brl,
     109NTSTATUS brlock_locktest(struct brl_context *brl,
    111110                      struct brl_handle *brlh,
    112111                      uint32_t smbpid,
     
    121120 Remove any locks associated with a open file.
    122121*/
    123 NTSTATUS brl_close(struct brl_context *brl,
     122NTSTATUS brlock_close(struct brl_context *brl,
    124123                   struct brl_handle *brlh)
    125124{
     
    130129 Get a number of locks associated with a open file.
    131130*/
    132 NTSTATUS brl_count(struct brl_context *brl,
     131NTSTATUS brlock_count(struct brl_context *brl,
    133132                   struct brl_handle *brlh,
    134133                   int *count)
  • vendor/current/source4/ntvfs/common/brlock.h

    r740 r988  
    2525        struct brl_context *(*brl_init)(TALLOC_CTX *, struct server_id ,
    2626                                        struct loadparm_context *lp_ctx,
    27                                         struct messaging_context *);
     27                                        struct imessaging_context *);
    2828        struct brl_handle *(*brl_create_handle)(TALLOC_CTX *, struct ntvfs_handle *, DATA_BLOB *);
    2929        NTSTATUS (*brl_lock)(struct brl_context *,
     
    5252};
    5353
    54 
    55 void brl_set_ops(const struct brlock_ops *new_ops);
     54void brlock_set_ops(const struct brlock_ops *new_ops);
    5655void brl_tdb_init_ops(void);
    57 void brl_ctdb_init_ops(void);
    58 
  • vendor/current/source4/ntvfs/common/brlock_tdb.c

    r740 r988  
    2727#include "includes.h"
    2828#include "system/filesys.h"
    29 #include <tdb.h>
    3029#include "messaging/messaging.h"
    31 #include "lib/util/tdb_wrap.h"
    3230#include "lib/messaging/irpc.h"
    3331#include "libcli/libcli.h"
     
    3634#include "ntvfs/ntvfs.h"
    3735#include "param/param.h"
     36#include "dbwrap/dbwrap.h"
    3837
    3938/*
     
    4746/* this struct is typicaly attached to tcon */
    4847struct brl_context {
    49         struct tdb_wrap *w;
     48        struct db_context *db;
    5049        struct server_id server;
    51         struct messaging_context *messaging_ctx;
     50        struct imessaging_context *imessaging_ctx;
    5251};
    5352
     
    9089/*
    9190  Open up the brlock.tdb database. Close it down using
    92   talloc_free(). We need the messaging_ctx to allow for
     91  talloc_free(). We need the imessaging_ctx to allow for
    9392  pending lock notifications.
    9493*/
    9594static struct brl_context *brl_tdb_init(TALLOC_CTX *mem_ctx, struct server_id server,
    9695                                        struct loadparm_context *lp_ctx,
    97                                     struct messaging_context *messaging_ctx)
     96                                    struct imessaging_context *imessaging_ctx)
    9897{
    9998        struct brl_context *brl;
     
    104103        }
    105104
    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) {
    108107                talloc_free(brl);
    109108                return NULL;
     
    111110
    112111        brl->server = server;
    113         brl->messaging_ctx = messaging_ctx;
     112        brl->imessaging_ctx = imessaging_ctx;
    114113
    115114        return brl;
     
    152151                            struct lock_struct *lck2)
    153152{
    154         /* this extra check is not redundent - it copes with locks
     153        /* this extra check is not redundant - it copes with locks
    155154           that go beyond the end of 64 bit file space */
    156155        if (lck1->size != 0 &&
     
    243242
    244243        /* 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) {
    246245                return NT_STATUS_LOCK_NOT_GRANTED;
    247246        }
     
    303302        struct lock_struct lock, *locks=NULL;
    304303        NTSTATUS status;
     304        struct db_record *locked;
    305305
    306306        kbuf.dptr = brlh->key.data;
     
    311311        }
    312312
    313         if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
     313        locked = dbwrap_fetch_locked(brl->db, brl, kbuf);
     314        if (!locked) {
    314315                return NT_STATUS_INTERNAL_DB_CORRUPTION;
    315316        }
     
    329330
    330331                if (NT_STATUS_IS_OK(status)) {
    331                         tdb_chainunlock(brl->w->tdb, kbuf);
     332                        talloc_free(locked);
    332333                        return NT_STATUS_OK;
    333334                }
    334335        }
    335336
    336         dbuf = tdb_fetch(brl->w->tdb, kbuf);
     337        dbuf = dbwrap_record_get_value(locked);
    337338
    338339        lock.context.smbpid = smbpid;
     
    359360
    360361        /* 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);
    362364        if (!locks) {
    363365                status = NT_STATUS_NO_MEMORY;
    364366                goto fail;
    365         } else {
    366                 dbuf.dptr = (uint8_t *)locks;
    367         }
     367        }
     368        memcpy(locks, dbuf.dptr, dbuf.dsize);
    368369        locks[count] = lock;
     370
     371        dbuf.dptr = (unsigned char *)locks;
    369372        dbuf.dsize += sizeof(lock);
    370373
    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)) {
    373376                goto fail;
    374377        }
    375378
    376         free(dbuf.dptr);
    377         tdb_chainunlock(brl->w->tdb, kbuf);
     379        talloc_free(locked);
    378380
    379381        /* the caller needs to know if the real lock was granted. If
     
    387389
    388390 fail:
    389 
    390         free(dbuf.dptr);
    391         tdb_chainunlock(brl->w->tdb, kbuf);
     391        talloc_free(locked);
    392392        return status;
    393393}
     
    420420                                last_notice = i;
    421421                        }
    422                         messaging_send_ptr(brl->messaging_ctx, locks[i].context.server,
     422                        imessaging_send_ptr(brl->imessaging_ctx, locks[i].context.server,
    423423                                           MSG_BRL_RETRY, locks[i].notify_ptr);
    424424                }
     
    456456        struct lock_struct *locks, *lock;
    457457        struct lock_context context;
     458        struct db_record *locked;
    458459        NTSTATUS status;
    459460
     
    465466        }
    466467
    467         if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
     468        locked = dbwrap_fetch_locked(brl->db, brl, kbuf);
     469        if (!locked) {
    468470                return NT_STATUS_INTERNAL_DB_CORRUPTION;
    469471        }
    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);
    476473
    477474        context.smbpid = smbpid;
     
    510507                /* found it - delete it */
    511508                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)) {
    514511                                goto fail;
    515512                        }
     
    526523                       
    527524                        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)) {
    531528                                goto fail;
    532529                        }
    533530                }
    534                
    535                 free(dbuf.dptr);
    536                 tdb_chainunlock(brl->w->tdb, kbuf);
     531
     532                talloc_free(locked);
    537533                return NT_STATUS_OK;
    538534        }
     
    542538
    543539 fail:
    544         free(dbuf.dptr);
    545         tdb_chainunlock(brl->w->tdb, kbuf);
     540        talloc_free(locked);
    546541        return status;
    547542}
     
    561556        struct lock_struct *locks;
    562557        NTSTATUS status;
     558        struct db_record *locked;
    563559
    564560        kbuf.dptr = brlh->key.data;
    565561        kbuf.dsize = brlh->key.length;
    566562
    567         if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
     563        locked = dbwrap_fetch_locked(brl->db, brl, kbuf);
     564        if (!locked) {
    568565                return NT_STATUS_INTERNAL_DB_CORRUPTION;
    569566        }
    570567
    571         dbuf = tdb_fetch(brl->w->tdb, kbuf);
     568        dbuf = dbwrap_record_get_value(locked);
    572569        if (!dbuf.dptr) {
    573                 tdb_chainunlock(brl->w->tdb, kbuf);
     570                talloc_free(locked);
    574571                return NT_STATUS_RANGE_NOT_LOCKED;
    575572        }
     
    587584                        /* found it - delete it */
    588585                        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)) {
    591588                                        goto fail;
    592589                                }
     
    598595                                count--;
    599596                                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)) {
    602600                                        goto fail;
    603601                                }
    604602                        }
    605603                       
    606                         free(dbuf.dptr);
    607                         tdb_chainunlock(brl->w->tdb, kbuf);
     604                        talloc_free(locked);
    608605                        return NT_STATUS_OK;
    609606                }
     
    614611
    615612 fail:
    616         free(dbuf.dptr);
    617         tdb_chainunlock(brl->w->tdb, kbuf);
     613        talloc_free(locked);
    618614        return status;
    619615}
     
    632628        int count, i;
    633629        struct lock_struct lock, *locks;
     630        NTSTATUS status;
    634631
    635632        kbuf.dptr = brlh->key.data;
     
    640637        }
    641638
    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)) {
    644641                return NT_STATUS_OK;
     642        } else if (!NT_STATUS_IS_OK(status)) {
     643                return status;
    645644        }
    646645
     
    659658        for (i=0; i<count; i++) {
    660659                if (brl_tdb_conflict_other(&locks[i], &lock)) {
    661                         free(dbuf.dptr);
     660                        talloc_free(dbuf.dptr);
    662661                        return NT_STATUS_FILE_LOCK_CONFLICT;
    663662                }
    664663        }
    665664
    666         free(dbuf.dptr);
     665        talloc_free(dbuf.dptr);
    667666        return NT_STATUS_OK;
    668667}
     
    678677        int count, i, dcount=0;
    679678        struct lock_struct *locks;
     679        struct db_record *locked;
    680680        NTSTATUS status;
    681681
     
    683683        kbuf.dsize = brlh->key.length;
    684684
    685         if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
     685        locked = dbwrap_fetch_locked(brl->db, brl, kbuf);
     686        if (!locked) {
    686687                return NT_STATUS_INTERNAL_DB_CORRUPTION;
    687688        }
    688 
    689         dbuf = tdb_fetch(brl->w->tdb, kbuf);
     689        dbuf = dbwrap_record_get_value(locked);
    690690        if (!dbuf.dptr) {
    691                 tdb_chainunlock(brl->w->tdb, kbuf);
     691                talloc_free(locked);
    692692                return NT_STATUS_OK;
    693693        }
     
    717717
    718718        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);
    722720        } else if (dcount != 0) {
    723721                /* tell all pending lock holders for this file that
     
    728726                dbuf.dsize = count * sizeof(*locks);
    729727
    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);
    737731
    738732        return status;
     
    743737{
    744738        TDB_DATA kbuf, dbuf;
     739        NTSTATUS status;
    745740
    746741        kbuf.dptr = brlh->key.data;
     
    748743        *count = 0;
    749744
    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)) {
    757747                return NT_STATUS_OK;
    758         }
    759 
     748        } else if (!NT_STATUS_IS_OK(status)) {
     749                return status;
     750        }
    760751        *count = dbuf.dsize / sizeof(struct lock_struct);
    761752
    762         free(dbuf.dptr);
    763         tdb_chainunlock(brl->w->tdb, kbuf);
     753        talloc_free(dbuf.dptr);
    764754
    765755        return NT_STATUS_OK;
     
    780770void brl_tdb_init_ops(void)
    781771{
    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  
    2727#include "ntvfs/sysdep/sys_notify.h"
    2828
     29NTSTATUS ntvfs_common_init(void);
     30
    2931NTSTATUS ntvfs_common_init(void)
    3032{
  • vendor/current/source4/ntvfs/common/notify.c

    r740 r988  
    2626#include "includes.h"
    2727#include "system/filesys.h"
    28 #include <tdb.h>
    29 #include "../lib/util/util_tdb.h"
    3028#include "messaging/messaging.h"
    31 #include "lib/util/tdb_wrap.h"
    3229#include "lib/messaging/irpc.h"
    33 #include "librpc/gen_ndr/ndr_s4_notify.h"
     30#include "librpc/gen_ndr/ndr_notify.h"
    3431#include "../lib/util/dlinklist.h"
    3532#include "ntvfs/common/ntvfs_common.h"
     
    3835#include "param/param.h"
    3936#include "lib/util/tsort.h"
     37#include "lib/dbwrap/dbwrap.h"
     38#include "../lib/util/util_tdb.h"
    4039
    4140struct notify_context {
    42         struct tdb_wrap *w;
     41        struct db_context *db;
    4342        struct server_id server;
    44         struct messaging_context *messaging_ctx;
     43        struct imessaging_context *imessaging_ctx;
    4544        struct notify_list *list;
    4645        struct notify_array *array;
    47         int seqnum;
     46        int64_t seqnum;
    4847        struct sys_notify_context *sys_notify_ctx;
    4948};
     
    6463
    6564static NTSTATUS notify_remove_all(struct notify_context *notify);
    66 static void notify_handler(struct messaging_context *msg_ctx, void *private_data,
     65static void notify_handler(struct imessaging_context *msg_ctx, void *private_data,
    6766                           uint32_t msg_type, struct server_id server_id, DATA_BLOB *data);
    6867
     
    7271static int notify_destructor(struct notify_context *notify)
    7372{
    74         messaging_deregister(notify->messaging_ctx, MSG_PVFS_NOTIFY, notify);
     73        imessaging_deregister(notify->imessaging_ctx, MSG_PVFS_NOTIFY, notify);
    7574        notify_remove_all(notify);
    7675        return 0;
     
    7978/*
    8079  Open up the notify.tdb database. You should close it down using
    81   talloc_free(). We need the messaging_ctx to allow for notifications
     80  talloc_free(). We need the imessaging_ctx to allow for notifications
    8281  via internal messages
    8382*/
    8483struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
    85                                    struct messaging_context *messaging_ctx,
     84                                   struct imessaging_context *imessaging_ctx,
    8685                                   struct loadparm_context *lp_ctx,
    8786                                   struct tevent_context *ev,
     
    103102        }
    104103
    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) {
    107106                talloc_free(notify);
    108107                return NULL;
     
    110109
    111110        notify->server = server;
    112         notify->messaging_ctx = messaging_ctx;
     111        notify->imessaging_ctx = imessaging_ctx;
    113112        notify->list = NULL;
    114113        notify->array = NULL;
    115         notify->seqnum = tdb_get_seqnum(notify->w->tdb);
     114        notify->seqnum = dbwrap_get_seqnum(notify->db);
    116115
    117116        talloc_set_destructor(notify, notify_destructor);
     
    119118        /* register with the messaging subsystem for the notify
    120119           message type */
    121         messaging_register(notify->messaging_ctx, notify,
     120        imessaging_register(notify->imessaging_ctx, notify,
    122121                           MSG_PVFS_NOTIFY, notify_handler);
    123122
     
    131130  lock the notify db
    132131*/
    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);
     132static 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
     139static void notify_unlock(struct db_record *lock)
     140{
     141        talloc_free(lock);
    147142}
    148143
     
    156151        enum ndr_err_code ndr_err;
    157152        int seqnum;
    158 
    159         seqnum = tdb_get_seqnum(notify->w->tdb);
     153        NTSTATUS status;
     154
     155        seqnum = dbwrap_get_seqnum(notify->db);
    160156
    161157        if (seqnum == notify->seqnum && notify->array != NULL) {
     
    169165        NT_STATUS_HAVE_NO_MEMORY(notify->array);
    170166
    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)) {
    173169                return NT_STATUS_OK;
    174170        }
     
    179175        ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->array,
    180176                                       (ndr_pull_flags_fn_t)ndr_pull_notify_array);
    181         free(dbuf.dptr);
     177        talloc_free(dbuf.dptr);
    182178        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    183179                return ndr_map_error2ntstatus(ndr_err);
     
    204200        DATA_BLOB blob;
    205201        enum ndr_err_code ndr_err;
    206         int ret;
    207202        TALLOC_CTX *tmp_ctx;
     203        NTSTATUS status;
    208204
    209205        /* if possible, remove some depth arrays */
     
    215211        /* we might just be able to delete the record */
    216212        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);
    222214        }
    223215
     
    234226        dbuf.dptr = blob.data;
    235227        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);
    238231        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;
    244233}
    245234
     
    248237  handle incoming notify messages
    249238*/
    250 static void notify_handler(struct messaging_context *msg_ctx, void *private_data,
     239static void notify_handler(struct imessaging_context *msg_ctx, void *private_data,
    251240                           uint32_t msg_type, struct server_id server_id, DATA_BLOB *data)
    252241{
     
    355344        size_t len;
    356345        int depth;
     346        struct db_record *locked;
    357347
    358348        /* see if change notify is enabled at all */
     
    361351        }
    362352
    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        }
    365357
    366358        status = notify_load(notify);
     
    416408
    417409done:
    418         notify_unlock(notify);
     410        notify_unlock(locked);
    419411        talloc_free(tmp_path);
    420412
     
    431423        int i, depth;
    432424        struct notify_depth *d;
     425        struct db_record *locked;
    433426
    434427        /* see if change notify is enabled at all */
     
    451444        talloc_free(listel);
    452445
    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        }
    455450
    456451        status = notify_load(notify);
    457452        if (!NT_STATUS_IS_OK(status)) {
    458                 notify_unlock(notify);
     453                notify_unlock(locked);
    459454                return status;
    460455        }
    461456
    462457        if (depth >= notify->array->num_depths) {
    463                 notify_unlock(notify);
     458                notify_unlock(locked);
    464459                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
    465460        }
     
    475470        }
    476471        if (i == d->num_entries) {
    477                 notify_unlock(notify);
     472                notify_unlock(locked);
    478473                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
    479474        }
     
    487482        status = notify_save(notify);
    488483
    489         notify_unlock(notify);
     484        notify_unlock(locked);
    490485
    491486        return status;
     
    499494        NTSTATUS status;
    500495        int i, depth, del_count=0;
     496        struct db_record *locked;
    501497
    502498        if (notify->list == NULL) {
     
    504500        }
    505501
    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        }
    508506
    509507        status = notify_load(notify);
    510508        if (!NT_STATUS_IS_OK(status)) {
    511                 notify_unlock(notify);
     509                notify_unlock(locked);
    512510                return status;
    513511        }
     
    534532        }
    535533
    536         notify_unlock(notify);
     534        notify_unlock(locked);
    537535
    538536        return status;
     
    553551
    554552        ev.action = action;
     553        ev.dir = discard_const_p(char, "");
    555554        ev.path = path;
    556555        ev.private_data = e->private_data;
     
    564563        }
    565564
    566         status = messaging_send(notify->messaging_ctx, e->server,
     565        status = imessaging_send(notify->imessaging_ctx, e->server,
    567566                                MSG_PVFS_NOTIFY, &data);
     567        if (!NT_STATUS_IS_OK(status)) {
     568                talloc_free(tmp_ctx);
     569                return;
     570        }
     571
    568572        talloc_free(tmp_ctx);
    569573}
  • vendor/current/source4/ntvfs/common/opendb.c

    r414 r988  
    5656/*
    5757  Open up the openfiles.tdb database. Close it down using
    58   talloc_free(). We need the messaging_ctx to allow for pending open
     58  talloc_free(). We need the imessaging_ctx to allow for pending open
    5959  notifications.
    6060*/
  • vendor/current/source4/ntvfs/common/opendb.h

    r414 r988  
    5858void odb_set_ops(const struct opendb_ops *new_ops);
    5959void odb_tdb_init_ops(void);
    60 void odb_ctdb_init_ops(void);
  • vendor/current/source4/ntvfs/common/opendb_tdb.c

    r740 r988  
    4141#include "includes.h"
    4242#include "system/filesys.h"
    43 #include <tdb.h>
     43#include "lib/dbwrap/dbwrap.h"
    4444#include "messaging/messaging.h"
    45 #include "lib/util/tdb_wrap.h"
    4645#include "lib/messaging/irpc.h"
    4746#include "librpc/gen_ndr/ndr_opendb.h"
     
    5352
    5453struct odb_context {
    55         struct tdb_wrap *w;
     54        struct db_context *db;
    5655        struct ntvfs_context *ntvfs_ctx;
    5756        bool oplocks;
     
    6564struct odb_lock {
    6665        struct odb_context *odb;
    67         TDB_DATA key;
     66        struct db_record *locked;
    6867
    6968        struct opendb_file file;
     
    7574};
    7675
    77 static NTSTATUS odb_oplock_break_send(struct messaging_context *msg_ctx,
     76static NTSTATUS odb_oplock_break_send(struct imessaging_context *msg_ctx,
    7877                                      struct opendb_entry *e,
    7978                                      uint8_t level);
     
    8180/*
    8281  Open up the openfiles.tdb database. Close it down using
    83   talloc_free(). We need the messaging_ctx to allow for pending open
     82  talloc_free(). We need the imessaging_ctx to allow for pending open
    8483  notifications.
    8584*/
     
    9493        }
    9594
    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) {
    9898                talloc_free(odb);
    9999                return NULL;
     
    112112}
    113113
    114 /*
    115   destroy a lock on the database
    116 */
    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 
    123114static NTSTATUS odb_pull_record(struct odb_lock *lck, struct opendb_file *file);
    124115
     
    132123        struct odb_lock *lck;
    133124        NTSTATUS status;
     125        TDB_DATA key;
    134126
    135127        lck = talloc(mem_ctx, struct odb_lock);
     
    139131
    140132        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) {
    144136                talloc_free(lck);
    145137                return NULL;
    146138        }
    147139
    148         if (tdb_chainlock(odb->w->tdb, lck->key) != 0) {
     140        lck->locked = dbwrap_fetch_locked(odb->db, lck, key);
     141        if (!lck->locked) {
    149142                talloc_free(lck);
    150143                return NULL;
     
    152145
    153146        ZERO_STRUCT(lck->can_open);
    154 
    155         talloc_set_destructor(lck, odb_lock_destructor);
    156147
    157148        status = odb_pull_record(lck, &lck->file);
     
    169160static DATA_BLOB odb_tdb_get_key(TALLOC_CTX *mem_ctx, struct odb_lock *lck)
    170161{
    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);
    172164}
    173165
     
    234226static NTSTATUS odb_pull_record(struct odb_lock *lck, struct opendb_file *file)
    235227{
    236         struct odb_context *odb = lck->odb;
    237228        TDB_DATA dbuf;
    238229        DATA_BLOB blob;
    239230        enum ndr_err_code ndr_err;
    240231
    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) {
    243234                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
    244235        }
     
    248239
    249240        ndr_err = ndr_pull_struct_blob(&blob, lck, file, (ndr_pull_flags_fn_t)ndr_pull_opendb_file);
    250         free(dbuf.dptr);
    251241        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    252242                return ndr_map_error2ntstatus(ndr_err);
     
    261251static NTSTATUS odb_push_record(struct odb_lock *lck, struct opendb_file *file)
    262252{
    263         struct odb_context *odb = lck->odb;
    264253        TDB_DATA dbuf;
    265254        DATA_BLOB blob;
    266255        enum ndr_err_code ndr_err;
    267         int ret;
     256        NTSTATUS status;
    268257
    269258        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);
    275260        }
    276261
     
    283268        dbuf.dsize = blob.length;
    284269               
    285         ret = tdb_store(odb->w->tdb, lck->key, dbuf, TDB_REPLACE);
     270        status = dbwrap_record_store(lck->locked, dbuf, TDB_REPLACE);
    286271        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;
    292273}
    293274
     
    295276  send an oplock break to a client
    296277*/
    297 static NTSTATUS odb_oplock_break_send(struct messaging_context *msg_ctx,
     278static NTSTATUS odb_oplock_break_send(struct imessaging_context *msg_ctx,
    298279                                      struct opendb_entry *e,
    299280                                      uint8_t level)
     
    312293        blob = data_blob_const(&op_break, sizeof(op_break));
    313294
    314         status = messaging_send(msg_ctx, e->server,
     295        status = imessaging_send(msg_ctx, e->server,
    315296                                MSG_NTVFS_OPLOCK_BREAK, &blob);
    316297        NT_STATUS_NOT_OK_RETURN(status);
     
    612593        /* send any pending notifications, removing them once sent */
    613594        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,
    615596                                   lck->file.pending[i].server,
    616597                                   MSG_PVFS_RETRY_OPEN,
     
    667648        /* send any pending notifications, removing them once sent */
    668649        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,
    670651                                   lck->file.pending[i].server,
    671652                                   MSG_PVFS_RETRY_OPEN,
  • vendor/current/source4/ntvfs/common/wscript_build

    r740 r988  
    44        source='init.c brlock.c brlock_tdb.c opendb.c opendb_tdb.c notify.c',
    55        autoproto='proto.h',
     6        deps='util_tdb tdb-wrap',
    67        public_deps='NDR_OPENDB NDR_NOTIFY sys_notify sys_lease share'
    78        )
Note: See TracChangeset for help on using the changeset viewer.