From: Ralph Boehme Date: Mon, 28 Sep 2020 08:35:32 +0000 (+0200) Subject: smbd: use fh_[get|set]_gen_id() X-Git-Tag: samba-4.14.0rc1~409 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=059dee953d6cc443eb2cd81d9d92cdeedc9390ea;p=thirdparty%2Fsamba.git smbd: use fh_[get|set]_gen_id() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index 8ad9341a765..1bf6d3deb48 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -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) { diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 28bf97b4775..92f122d8e3d 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -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)) { diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index 6aeaa202798..c74d9aa2753 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -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); diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 7a5afa2f082..53775ce3cab 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -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"); } diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index d4062f7a66c..d02872a610f 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -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; } diff --git a/source3/smbd/oplock_linux.c b/source3/smbd/oplock_linux.c index 37e2d8e171a..a1571aad46b 100644 --- a/source3/smbd/oplock_linux.c +++ b/source3/smbd/oplock_linux.c @@ -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)); } }