]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: use fh_[get|set]_gen_id()
authorRalph Boehme <slow@samba.org>
Mon, 28 Sep 2020 08:35:32 +0000 (10:35 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 16 Dec 2020 09:08:30 +0000 (09:08 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/share_mode_lock.c
source3/smbd/close.c
source3/smbd/durable.c
source3/smbd/files.c
source3/smbd/oplock.c
source3/smbd/oplock_linux.c

index 8ad9341a765c907a7dc84719675419981863ea7c..1bf6d3deb487fa1f7e67944359c8b58bc49b0d6f 100644 (file)
@@ -55,6 +55,7 @@
 #include "../lib/util/memcache.h"
 #include "lib/util/tevent_ntstatus.h"
 #include "g_lock.h"
+#include "smbd/fd_handle.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_LOCKING
@@ -1790,7 +1791,7 @@ bool set_share_mode(struct share_mode_lock *lck,
                ltdb->share_entries,
                ltdb->num_share_entries,
                my_pid,
-               fsp->fh->gen_id,
+               fh_get_gen_id(fsp->fh),
                &e,
                &found);
        if (found) {
@@ -1808,7 +1809,7 @@ bool set_share_mode(struct share_mode_lock *lck,
                .op_type = op_type,
                .time.tv_sec = fsp->open_time.tv_sec,
                .time.tv_usec = fsp->open_time.tv_usec,
-               .share_file_id = fsp->fh->gen_id,
+               .share_file_id = fh_get_gen_id(fsp->fh),
                .uid = (uint32_t)uid,
                .flags = (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) ?
                        SHARE_MODE_FLAG_POSIX_OPEN : 0,
@@ -2279,7 +2280,7 @@ bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp)
        ok = share_mode_entry_do(
                lck,
                messaging_server_id(fsp->conn->sconn->msg_ctx),
-               fsp->fh->gen_id,
+               fh_get_gen_id(fsp->fh),
                del_share_mode_fn,
                &state);
        if (!ok) {
@@ -2318,7 +2319,7 @@ bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp)
        ok = share_mode_entry_do(
                lck,
                messaging_server_id(fsp->conn->sconn->msg_ctx),
-               fsp->fh->gen_id,
+               fh_get_gen_id(fsp->fh),
                remove_share_oplock_fn,
                &state);
        if (!ok) {
@@ -2367,7 +2368,7 @@ bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp)
        ok = share_mode_entry_do(
                lck,
                messaging_server_id(fsp->conn->sconn->msg_ctx),
-               fsp->fh->gen_id,
+               fh_get_gen_id(fsp->fh),
                downgrade_share_oplock_fn,
                &state);
        if (!ok) {
@@ -2429,7 +2430,7 @@ bool mark_share_mode_disconnected(struct share_mode_lock *lck,
        ok = share_mode_entry_do(
                lck,
                messaging_server_id(fsp->conn->sconn->msg_ctx),
-               fsp->fh->gen_id,
+               fh_get_gen_id(fsp->fh),
                mark_share_mode_disconnected_fn,
                &state);
        if (!ok) {
index 28bf97b4775b008473241d6e3ec6a7d932b3e539..92f122d8e3d187403b44fd4fa1c7ee6ef058bd17 100644 (file)
@@ -243,7 +243,7 @@ static bool has_other_nonposix_opens_fn(
            (e->flags & SHARE_MODE_FLAG_POSIX_OPEN)) {
                return false;
        }
-       if (e->share_file_id == fsp->fh->gen_id) {
+       if (e->share_file_id == fh_get_gen_id(fsp->fh)) {
                struct server_id self = messaging_server_id(
                        fsp->conn->sconn->msg_ctx);
                if (server_id_equal(&self, &e->pid)) {
index 6aeaa202798d9375fd75e5beeee38288de6dd8d7..c74d9aa27533bfc24dd973cf344efca68e9635dd 100644 (file)
@@ -781,7 +781,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn,
                e.share_file_id,
                messaging_server_id(conn->sconn->msg_ctx),
                smb1req->mid,
-               fsp->fh->gen_id);
+               fh_get_gen_id(fsp->fh));
        if (!ok) {
                DBG_DEBUG("Could not set new share_mode_entry values\n");
                TALLOC_FREE(lck);
index 7a5afa2f082d8e5a2187e4161acc708f80510084..53775ce3cab57fc300ce2e6b691f31267ebbbf46 100644 (file)
@@ -88,7 +88,8 @@ void fsp_set_gen_id(files_struct *fsp)
         * A billion of 64-bit increments per second gives us
         * more than 500 years of runtime without wrap.
         */
-       fsp->fh->gen_id = gen_id++;
+       gen_id++;
+       fh_set_gen_id(fsp->fh, gen_id);
 }
 
 /****************************************************************************
@@ -414,7 +415,7 @@ files_struct *file_find_dif(struct smbd_server_connection *sconn,
        for (fsp=sconn->files; fsp; fsp=fsp->next,count++) {
                /* We can have a fsp->fh->fd == -1 here as it could be a stat open. */
                if (file_id_equal(&fsp->file_id, &id) &&
-                   fsp->fh->gen_id == gen_id ) {
+                   fh_get_gen_id(fsp->fh) == gen_id ) {
                        if (count > 10) {
                                DLIST_PROMOTE(sconn->files, fsp);
                        }
@@ -428,7 +429,7 @@ files_struct *file_find_dif(struct smbd_server_connection *sconn,
                                         "stat open with oplock type !\n",
                                         fsp_str_dbg(fsp),
                                         file_id_str_buf(fsp->file_id, &idbuf),
-                                        (unsigned int)fsp->fh->gen_id,
+                                        (unsigned int)fh_get_gen_id(fsp->fh),
                                         (unsigned int)fsp->oplock_type ));
                                smb_panic("file_find_dif");
                        }
index d4062f7a66cdb64556c68a46c1f25a449d14886d..d02872a610f303f4540732d0653c25f5c9d21cce 100644 (file)
@@ -38,7 +38,7 @@ void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp)
 
        /* Put the kernel break info into the message. */
        push_file_id_24((char *)msg, &fsp->file_id);
-       SIVAL(msg,24,fsp->fh->gen_id);
+       SIVAL(msg, 24, fh_get_gen_id(fsp->fh));
 
        /* Don't need to be root here as we're only ever
           sending to ourselves. */
@@ -85,7 +85,7 @@ NTSTATUS set_file_oplock(files_struct *fsp)
                 "tv_sec = %x, tv_usec = %x\n",
                 fsp_str_dbg(fsp),
                 file_id_str_buf(fsp->file_id, &buf),
-                fsp->fh->gen_id,
+                fh_get_gen_id(fsp->fh),
                 (int)fsp->open_time.tv_sec,
                 (int)fsp->open_time.tv_usec);
 
@@ -789,7 +789,7 @@ static files_struct *initial_break_processing(
                           "Allowing break to succeed regardless.\n",
                           fsp_str_dbg(fsp),
                           file_id_str_buf(id, &idbuf),
-                          fsp->fh->gen_id);
+                          fh_get_gen_id(fsp->fh));
                return NULL;
        }
 
index 37e2d8e171a172ed70d0d78b5a23533c3baef367..a1571aad46bb871ceec8434c175977ef7c593b6d 100644 (file)
@@ -132,7 +132,7 @@ static bool linux_set_kernel_oplock(struct kernel_oplocks *ctx,
                   "file_id = %s gen_id = %"PRIu64"\n",
                   fsp_str_dbg(fsp),
                   file_id_str_buf(fsp->file_id, &idbuf),
-                  fsp->fh->gen_id);
+                  fh_get_gen_id(fsp->fh));
 
        return True;
 }
@@ -157,7 +157,7 @@ static void linux_release_kernel_oplock(struct kernel_oplocks *ctx,
                        "of %x.\n",
                        fsp_str_dbg(fsp),
                        file_id_str_buf(fsp->file_id, &idbuf),
-                       fsp->fh->gen_id,
+                       fh_get_gen_id(fsp->fh),
                        state);
        }
 
@@ -172,7 +172,7 @@ static void linux_release_kernel_oplock(struct kernel_oplocks *ctx,
                                "Error was %s\n",
                                fsp_str_dbg(fsp),
                                file_id_str_buf(fsp->file_id, &idbuf),
-                               fsp->fh->gen_id,
+                               fh_get_gen_id(fsp->fh),
                                strerror(errno));
                }
        }