~lefteris-nikoltsios/+junk/samba-lp1016895

« back to all changes in this revision

Viewing changes to source3/modules/vfs_syncops.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * ensure meta data operations are performed synchronously
3
3
 *
4
4
 * Copyright (C) Andrew Tridgell     2007
 
5
 * Copyright (C) Christian Ambach, 2010-2011
5
6
 *
6
7
 * This program is free software; you can redistribute it and/or modify
7
8
 * it under the terms of the GNU General Public License as published by
19
20
 */
20
21
 
21
22
#include "includes.h"
 
23
#include "system/filesys.h"
 
24
#include "smbd/smbd.h"
22
25
 
23
26
/*
24
27
 
31
34
 
32
35
  On those filesystems this module provides a way to perform those
33
36
  operations safely.  
34
 
 */
35
37
 
36
 
/*
37
38
  most of the performance loss with this module is in fsync on close(). 
38
 
  You can disable that with syncops:onclose = no
 
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
 
39
51
 */
40
 
static bool sync_onclose;
 
52
 
 
53
struct syncops_config_data {
 
54
        bool onclose;
 
55
        bool onmeta;
 
56
        bool disable;
 
57
};
41
58
 
42
59
/*
43
60
  given a filename, find the parent directory
125
142
                          const struct smb_filename *smb_fname_src,
126
143
                          const struct smb_filename *smb_fname_dst)
127
144
{
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) {
130
155
                syncops_two_names(smb_fname_src->base_name,
131
156
                                  smb_fname_dst->base_name);
132
157
        }
135
160
 
136
161
/* handle the rest with a macro */
137
162
#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); \
140
172
        return ret; \
141
173
} while (0)
142
174
 
143
175
#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); \
146
185
        return ret; \
147
186
} while (0)
148
187
 
191
230
/* close needs to be handled specially */
192
231
static int syncops_close(vfs_handle_struct *handle, files_struct *fsp)
193
232
{
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) {
195
240
                /* ideally we'd only do this if we have written some
196
241
                 data, but there is no flag for that in fsp yet. */
197
242
                fsync(fsp->fh->fd);
199
244
        return SMB_VFS_NEXT_CLOSE(handle, fsp);
200
245
}
201
246
 
 
247
static int syncops_connect(struct vfs_handle_struct *handle, const char *service,
 
248
                           const char *user)
 
249
{
 
250
 
 
251
        struct syncops_config_data *config;
 
252
        int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
 
253
        if (ret < 0) {
 
254
                return ret;
 
255
        }
 
256
 
 
257
        config = talloc_zero(handle->conn, struct syncops_config_data);
 
258
        if (!config) {
 
259
                SMB_VFS_NEXT_DISCONNECT(handle);
 
260
                DEBUG(0, ("talloc_zero() failed\n"));
 
261
                return -1;
 
262
        }
 
263
 
 
264
        config->onclose = lp_parm_bool(SNUM(handle->conn), "syncops",
 
265
                                        "onclose", true);
 
266
 
 
267
        config->onmeta = lp_parm_bool(SNUM(handle->conn), "syncops",
 
268
                                        "onmeta", true);
 
269
 
 
270
        config->disable = lp_parm_bool(SNUM(handle->conn), "syncops",
 
271
                                        "disable", false);
 
272
 
 
273
        SMB_VFS_HANDLE_SET_DATA(handle, config,
 
274
                                NULL, struct syncops_config_data,
 
275
                                return -1);
 
276
 
 
277
        return 0;
 
278
 
 
279
}
202
280
 
203
281
static struct vfs_fn_pointers vfs_syncops_fns = {
 
282
        .connect_fn = syncops_connect,
204
283
        .mkdir = syncops_mkdir,
205
284
        .rmdir = syncops_rmdir,
206
 
        .open = syncops_open,
 
285
        .open_fn = syncops_open,
207
286
        .rename = syncops_rename,
208
287
        .unlink = syncops_unlink,
209
288
        .symlink = syncops_symlink,
222
301
        if (!NT_STATUS_IS_OK(ret))
223
302
                return ret;
224
303
 
225
 
        sync_onclose = lp_parm_bool(-1, "syncops", "onclose", true);
226
 
        
227
304
        return ret;
228
305
}