Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/modules/vfs_syncops.c

    r414 r745  
    33 *
    44 * Copyright (C) Andrew Tridgell     2007
     5
    56 *
    67 * This program is free software; you can redistribute it and/or modify
     
    2021
    2122#include "includes.h"
     23
     24
    2225
    2326/*
     
    3235  On those filesystems this module provides a way to perform those
    3336  operations safely. 
    34  */
    35 
    36 /*
     37
    3738  most of the performance loss with this module is in fsync on close().
    38   You can disable that with syncops:onclose = no
    39  */
    40 static bool sync_onclose;
     39  You can disable that with
     40     syncops:onclose = no
     41  that can be set either globally or per share.
     42
     43  On certain filesystems that only require the last data written to be
     44  fsync()'ed, you can disable the metadata synchronization of this module with
     45     syncops:onmeta = no
     46  This option can be set either globally or per share.
     47
     48  you can also disable the module completely for a share with
     49     syncops:disable = true
     50
     51 */
     52
     53struct syncops_config_data {
     54        bool onclose;
     55        bool onmeta;
     56        bool disable;
     57};
    4158
    4259/*
     
    126143                          const struct smb_filename *smb_fname_dst)
    127144{
    128         int ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
    129         if (ret == 0) {
     145
     146        int ret;
     147        struct syncops_config_data *config;
     148
     149        SMB_VFS_HANDLE_GET_DATA(handle, config,
     150                                struct syncops_config_data,
     151                                return -1);
     152
     153        ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
     154        if (ret == 0 && config->onmeta && !config->disable) {
    130155                syncops_two_names(smb_fname_src->base_name,
    131156                                  smb_fname_dst->base_name);
     
    136161/* handle the rest with a macro */
    137162#define SYNCOPS_NEXT(op, fname, args) do {   \
    138         int ret = SMB_VFS_NEXT_ ## op args; \
    139         if (ret == 0 && fname) syncops_name(fname); \
     163        int ret; \
     164        struct syncops_config_data *config; \
     165        SMB_VFS_HANDLE_GET_DATA(handle, config, \
     166                                struct syncops_config_data, \
     167                                return -1); \
     168        ret = SMB_VFS_NEXT_ ## op args; \
     169        if (ret == 0 \
     170                && config->onmeta && !config->disable  \
     171                && fname) syncops_name(fname); \
    140172        return ret; \
    141173} while (0)
    142174
    143175#define SYNCOPS_NEXT_SMB_FNAME(op, fname, args) do {   \
    144         int ret = SMB_VFS_NEXT_ ## op args; \
    145         if (ret == 0 && fname) syncops_smb_fname(fname); \
     176        int ret; \
     177        struct syncops_config_data *config; \
     178        SMB_VFS_HANDLE_GET_DATA(handle, config, \
     179                                struct syncops_config_data, \
     180                                return -1); \
     181        ret = SMB_VFS_NEXT_ ## op args; \
     182        if (ret == 0 \
     183        && config->onmeta && !config->disable \
     184        && fname) syncops_smb_fname(fname); \
    146185        return ret; \
    147186} while (0)
     
    192231static int syncops_close(vfs_handle_struct *handle, files_struct *fsp)
    193232{
    194         if (fsp->can_write && sync_onclose) {
     233        struct syncops_config_data *config;
     234
     235        SMB_VFS_HANDLE_GET_DATA(handle, config,
     236                                struct syncops_config_data,
     237                                return -1);
     238
     239        if (fsp->can_write && config->onclose) {
    195240                /* ideally we'd only do this if we have written some
    196241                 data, but there is no flag for that in fsp yet. */
     
    200245}
    201246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
    202280
    203281static struct vfs_fn_pointers vfs_syncops_fns = {
     282
    204283        .mkdir = syncops_mkdir,
    205284        .rmdir = syncops_rmdir,
    206         .open = syncops_open,
     285        .open = syncops_open,
    207286        .rename = syncops_rename,
    208287        .unlink = syncops_unlink,
     
    223302                return ret;
    224303
    225         sync_onclose = lp_parm_bool(-1, "syncops", "onclose", true);
    226        
    227304        return ret;
    228305}
Note: See TracChangeset for help on using the changeset viewer.