]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
add new module parameter 'enable_oplocks'
authorSteve French <smfrench@gmail.com>
Wed, 12 Oct 2011 22:47:03 +0000 (17:47 -0500)
committerSteve French <smfrench@gmail.com>
Thu, 13 Oct 2011 04:42:05 +0000 (23:42 -0500)
Thus spake Jeff Layton:

"Making that a module parm would allow you to set that parameter at boot
time without needing to add special startup scripts. IMO, all of the
procfile "switches" under /proc/fs/cifs should be module parms
instead."

This patch doesn't alter the default behavior (Oplocks are enabled by
default).

To disable oplocks when loading the module, use

   modprobe cifs enable_oplocks=0

(any of '0' or 'n' or 'N' conventions can be used).

To disable oplocks at runtime using the new interface, use

   echo 0 > /sys/module/cifs/parameters/enable_oplocks

The older /proc/fs/cifs/OplockEnabled interface will be deprecated
after two releases. A subsequent patch will add an warning message
about this deprecation.

Changes since v2:
   - make enable_oplocks a 'bool'

Changes since v1:
   - eliminate the use of extra variable by renaming the old one to
     enable_oplocks and make it an 'int' type.

Reported-by: Alexander Swen <alex@swen.nu>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/cifs_debug.c
fs/cifs/cifsfs.c
fs/cifs/cifsglob.h
fs/cifs/dir.c
fs/cifs/file.c

index 6d40656e1e2994ad4fedbdcb9645b2367dbce3b7..e1715313f3981ead34a318031b6454da9d56d3f7 100644 (file)
@@ -511,7 +511,7 @@ static const struct file_operations cifsFYI_proc_fops = {
 
 static int cifs_oplock_proc_show(struct seq_file *m, void *v)
 {
-       seq_printf(m, "%d\n", oplockEnabled);
+       seq_printf(m, "%d\n", enable_oplocks);
        return 0;
 }
 
@@ -530,9 +530,9 @@ static ssize_t cifs_oplock_proc_write(struct file *file,
        if (rc)
                return rc;
        if (c == '0' || c == 'n' || c == 'N')
-               oplockEnabled = 0;
+               enable_oplocks = false;
        else if (c == '1' || c == 'y' || c == 'Y')
-               oplockEnabled = 1;
+               enable_oplocks = true;
 
        return count;
 }
index aa8fe7cee0b44ac33fc3ddf2b6fed0d1a9dacc5c..5c29721068161e0cc4722fbe19c06d9ee2c80b88 100644 (file)
@@ -53,7 +53,7 @@
 int cifsFYI = 0;
 int cifsERROR = 1;
 int traceSMB = 0;
-unsigned int oplockEnabled = 1;
+bool enable_oplocks = true;
 unsigned int linuxExtEnabled = 1;
 unsigned int lookupCacheEnabled = 1;
 unsigned int multiuser_mount = 0;
@@ -82,6 +82,10 @@ module_param(echo_retries, ushort, 0644);
 MODULE_PARM_DESC(echo_retries, "Number of echo attempts before giving up and "
                               "reconnecting server. Default: 5. 0 means "
                               "never reconnect.");
+module_param(enable_oplocks, bool, 0644);
+MODULE_PARM_DESC(enable_oplocks, "Enable or disable oplocks (bool). Default:"
+                                "y/Y/1");
+
 extern mempool_t *cifs_sm_req_poolp;
 extern mempool_t *cifs_req_poolp;
 extern mempool_t *cifs_mid_poolp;
index 95dad9d14cf10211156e1896c0e97d270d76ab2f..d734dee9d495d77dce5631a13bf98a6224df95e1 100644 (file)
@@ -964,7 +964,8 @@ GLOBAL_EXTERN unsigned int multiuser_mount; /* if enabled allows new sessions
                                to be established on existing mount if we
                                have the uid/password or Kerberos credential
                                or equivalent for current user */
-GLOBAL_EXTERN unsigned int oplockEnabled;
+/* enable or disable oplocks */
+GLOBAL_EXTERN bool enable_oplocks;
 GLOBAL_EXTERN unsigned int lookupCacheEnabled;
 GLOBAL_EXTERN unsigned int global_secflags;    /* if on, session setup sent
                                with more secure ntlmssp2 challenge/resp */
index 72d448bf96ce57d8f6ed770277da46a3e3d7ace4..4dd5333753fa771cbe7d245334accf7e0cdaf408 100644 (file)
@@ -171,7 +171,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
        }
        tcon = tlink_tcon(tlink);
 
-       if (oplockEnabled)
+       if (enable_oplocks)
                oplock = REQ_OPLOCK;
 
        if (nd)
index fd57165f55fa0bedaf9d5450b4680833d89272e7..8e184150cfb579be04a4d8c988cecb83ce2c0d5e 100644 (file)
@@ -371,7 +371,7 @@ int cifs_open(struct inode *inode, struct file *file)
        cFYI(1, "inode = 0x%p file flags are 0x%x for %s",
                 inode, file->f_flags, full_path);
 
-       if (oplockEnabled)
+       if (enable_oplocks)
                oplock = REQ_OPLOCK;
        else
                oplock = 0;
@@ -495,7 +495,7 @@ static int cifs_reopen_file(struct cifsFileInfo *pCifsFile, bool can_flush)
        cFYI(1, "inode = 0x%p file flags 0x%x for %s",
                 inode, pCifsFile->f_flags, full_path);
 
-       if (oplockEnabled)
+       if (enable_oplocks)
                oplock = REQ_OPLOCK;
        else
                oplock = 0;