]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: move files_struct.is_sparse to a bitfield
authorRalph Boehme <slow@samba.org>
Fri, 3 Apr 2020 05:52:10 +0000 (07:52 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 3 Apr 2020 19:05:44 +0000 (19:05 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/include/vfs.h
source3/modules/vfs_default.c
source3/modules/vfs_gpfs.c
source3/smbd/dosmode.c
source3/smbd/fileio.c
source3/smbd/open.c
source3/smbd/smb2_ioctl_filesys.c

index 6f7670eee14ea7f69a0f3c0ccfa77b98d0377c2d..f3810736ba9359bc7e3391a6b44d1827186efbe5 100644 (file)
@@ -370,6 +370,7 @@ typedef struct files_struct {
                bool aio_write_behind : 1;
                bool initial_delete_on_close : 1;
                bool delete_on_close : 1;
+               bool is_sparse : 1;
        } fsp_flags;
 
        struct tevent_timer *update_write_time_event;
@@ -391,7 +392,6 @@ typedef struct files_struct {
        int current_lock_count; /* Count the number of outstanding locks and pending locks. */
 
        uint64_t posix_flags;
-       bool is_sparse;
        bool backup_intent; /* Handle was successfully opened with backup intent
                                and opener has privilege to do so. */
        bool use_ofd_locks; /* Are we using open file description locks ? */
index 42964c98499bc39f19748d2b8b869c161b5bc64c..3527d0371ce1e4c6564344fa23d90b7833ebb9e1 100644 (file)
@@ -2633,7 +2633,7 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, off_t
 
        START_PROFILE(syscall_ftruncate);
 
-       if (lp_strict_allocate(SNUM(fsp->conn)) && !fsp->is_sparse) {
+       if (lp_strict_allocate(SNUM(fsp->conn)) && !fsp->fsp_flags.is_sparse) {
                result = strict_allocate_ftruncate(handle, fsp, len);
                END_PROFILE(syscall_ftruncate);
                return result;
index ea88db868fc76c5b0d936526b85b968279221ab7..26b2c52ba98abbac273b05ad41f6eb9586ea06e0 100644 (file)
@@ -2073,7 +2073,7 @@ static int vfs_gpfs_fallocate(struct vfs_handle_struct *handle,
                              off_t offset, off_t len)
 {
        if (mode == (VFS_FALLOCATE_FL_PUNCH_HOLE|VFS_FALLOCATE_FL_KEEP_SIZE) &&
-           !fsp->is_sparse &&
+           !fsp->fsp_flags.is_sparse &&
            lp_strict_allocate(SNUM(fsp->conn))) {
                /*
                 * This is from a ZERO_DATA request on a non-sparse
index b9dbbbf58d6328b1d853e137c71efcf308c74654..b86642adcfe7a5f729641da7d51f8dc59771dc14 100644 (file)
@@ -1197,7 +1197,7 @@ NTSTATUS file_set_sparse(connection_struct *conn,
                     FILE_NOTIFY_CHANGE_ATTRIBUTES,
                     fsp->fsp_name->base_name);
 
-       fsp->is_sparse = sparse;
+       fsp->fsp_flags.is_sparse = sparse;
 
        return NT_STATUS_OK;
 }
index 14610eb225d60a27fd91f720797e613529d9ca05..6d58bdbbc97eeef3ec1c142f4ef9a5a2f071e886 100644 (file)
@@ -73,7 +73,7 @@ static ssize_t real_write_file(struct smb_request *req,
        fsp->fh->pos = pos;
        if (pos &&
            lp_strict_allocate(SNUM(fsp->conn)) &&
-           !fsp->is_sparse)
+           !fsp->fsp_flags.is_sparse)
        {
                if (vfs_fill_sparse(fsp, pos) == -1) {
                        return -1;
index 9eccd6231765292349c3118f491197a54f614bd2..3731e5df7cb5294ed0fb29358787c67c5e1471f7 100644 (file)
@@ -3998,9 +3998,9 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
        /* Determine sparse flag. */
        if (posix_open) {
                /* POSIX opens are sparse by default. */
-               fsp->is_sparse = true;
+               fsp->fsp_flags.is_sparse = true;
        } else {
-               fsp->is_sparse =
+               fsp->fsp_flags.is_sparse =
                        (existing_dos_attributes & FILE_ATTRIBUTE_SPARSE);
        }
 
index 8a9c8c64ec9ddbca4623251555f4792d76aa6e44..a398920bfedf00aa9f46cc5cf9bf9628b748cbae 100644 (file)
@@ -154,7 +154,7 @@ static NTSTATUS fsctl_dup_extents_check_sparse(struct files_struct *src_fsp,
         * is non-sparse, then FSCTL_DUPLICATE_EXTENTS_TO_FILE completes
         * successfully.
         */
-       if ((src_fsp->is_sparse) && (!dst_fsp->is_sparse)) {
+       if (src_fsp->fsp_flags.is_sparse && !dst_fsp->fsp_flags.is_sparse) {
                return NT_STATUS_NOT_SUPPORTED;
        }
 
@@ -509,7 +509,7 @@ static NTSTATUS fsctl_zero_data(TALLOC_CTX *mem_ctx,
                return status;
        }
 
-       if (!fsp->is_sparse && lp_strict_allocate(SNUM(fsp->conn))) {
+       if (!fsp->fsp_flags.is_sparse && lp_strict_allocate(SNUM(fsp->conn))) {
                /*
                 * File marked non-sparse and "strict allocate" is enabled -
                 * allocate the range that we just punched out.
@@ -699,7 +699,7 @@ static NTSTATUS fsctl_qar(TALLOC_CTX *mem_ctx,
        max_off = MIN(sbuf.st_ex_size,
                      qar_req.buf.file_off + qar_req.buf.len) - 1;
 
-       if (!fsp->is_sparse) {
+       if (!fsp->fsp_flags.is_sparse) {
                struct file_alloced_range_buf qar_buf;
 
                /* file is non-sparse, claim file_off->max_off is allocated */