1. 15 10月, 2010 1 次提交
    • A
      llseek: automatically add .llseek fop · 6038f373
      Arnd Bergmann 提交于
      All file_operations should get a .llseek operation so we can make
      nonseekable_open the default for future file operations without a
      .llseek pointer.
      
      The three cases that we can automatically detect are no_llseek, seq_lseek
      and default_llseek. For cases where we can we can automatically prove that
      the file offset is always ignored, we use noop_llseek, which maintains
      the current behavior of not returning an error from a seek.
      
      New drivers should normally not use noop_llseek but instead use no_llseek
      and call nonseekable_open at open time.  Existing drivers can be converted
      to do the same when the maintainer knows for certain that no user code
      relies on calling seek on the device file.
      
      The generated code is often incorrectly indented and right now contains
      comments that clarify for each added line why a specific variant was
      chosen. In the version that gets submitted upstream, the comments will
      be gone and I will manually fix the indentation, because there does not
      seem to be a way to do that using coccinelle.
      
      Some amount of new code is currently sitting in linux-next that should get
      the same modifications, which I will do at the end of the merge window.
      
      Many thanks to Julia Lawall for helping me learn to write a semantic
      patch that does all this.
      
      ===== begin semantic patch =====
      // This adds an llseek= method to all file operations,
      // as a preparation for making no_llseek the default.
      //
      // The rules are
      // - use no_llseek explicitly if we do nonseekable_open
      // - use seq_lseek for sequential files
      // - use default_llseek if we know we access f_pos
      // - use noop_llseek if we know we don't access f_pos,
      //   but we still want to allow users to call lseek
      //
      @ open1 exists @
      identifier nested_open;
      @@
      nested_open(...)
      {
      <+...
      nonseekable_open(...)
      ...+>
      }
      
      @ open exists@
      identifier open_f;
      identifier i, f;
      identifier open1.nested_open;
      @@
      int open_f(struct inode *i, struct file *f)
      {
      <+...
      (
      nonseekable_open(...)
      |
      nested_open(...)
      )
      ...+>
      }
      
      @ read disable optional_qualifier exists @
      identifier read_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      expression E;
      identifier func;
      @@
      ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
      {
      <+...
      (
         *off = E
      |
         *off += E
      |
         func(..., off, ...)
      |
         E = *off
      )
      ...+>
      }
      
      @ read_no_fpos disable optional_qualifier exists @
      identifier read_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      @@
      ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
      {
      ... when != off
      }
      
      @ write @
      identifier write_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      expression E;
      identifier func;
      @@
      ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
      {
      <+...
      (
        *off = E
      |
        *off += E
      |
        func(..., off, ...)
      |
        E = *off
      )
      ...+>
      }
      
      @ write_no_fpos @
      identifier write_f;
      identifier f, p, s, off;
      type ssize_t, size_t, loff_t;
      @@
      ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
      {
      ... when != off
      }
      
      @ fops0 @
      identifier fops;
      @@
      struct file_operations fops = {
       ...
      };
      
      @ has_llseek depends on fops0 @
      identifier fops0.fops;
      identifier llseek_f;
      @@
      struct file_operations fops = {
      ...
       .llseek = llseek_f,
      ...
      };
      
      @ has_read depends on fops0 @
      identifier fops0.fops;
      identifier read_f;
      @@
      struct file_operations fops = {
      ...
       .read = read_f,
      ...
      };
      
      @ has_write depends on fops0 @
      identifier fops0.fops;
      identifier write_f;
      @@
      struct file_operations fops = {
      ...
       .write = write_f,
      ...
      };
      
      @ has_open depends on fops0 @
      identifier fops0.fops;
      identifier open_f;
      @@
      struct file_operations fops = {
      ...
       .open = open_f,
      ...
      };
      
      // use no_llseek if we call nonseekable_open
      ////////////////////////////////////////////
      @ nonseekable1 depends on !has_llseek && has_open @
      identifier fops0.fops;
      identifier nso ~= "nonseekable_open";
      @@
      struct file_operations fops = {
      ...  .open = nso, ...
      +.llseek = no_llseek, /* nonseekable */
      };
      
      @ nonseekable2 depends on !has_llseek @
      identifier fops0.fops;
      identifier open.open_f;
      @@
      struct file_operations fops = {
      ...  .open = open_f, ...
      +.llseek = no_llseek, /* open uses nonseekable */
      };
      
      // use seq_lseek for sequential files
      /////////////////////////////////////
      @ seq depends on !has_llseek @
      identifier fops0.fops;
      identifier sr ~= "seq_read";
      @@
      struct file_operations fops = {
      ...  .read = sr, ...
      +.llseek = seq_lseek, /* we have seq_read */
      };
      
      // use default_llseek if there is a readdir
      ///////////////////////////////////////////
      @ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier readdir_e;
      @@
      // any other fop is used that changes pos
      struct file_operations fops = {
      ... .readdir = readdir_e, ...
      +.llseek = default_llseek, /* readdir is present */
      };
      
      // use default_llseek if at least one of read/write touches f_pos
      /////////////////////////////////////////////////////////////////
      @ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read.read_f;
      @@
      // read fops use offset
      struct file_operations fops = {
      ... .read = read_f, ...
      +.llseek = default_llseek, /* read accesses f_pos */
      };
      
      @ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier write.write_f;
      @@
      // write fops use offset
      struct file_operations fops = {
      ... .write = write_f, ...
      +	.llseek = default_llseek, /* write accesses f_pos */
      };
      
      // Use noop_llseek if neither read nor write accesses f_pos
      ///////////////////////////////////////////////////////////
      
      @ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read_no_fpos.read_f;
      identifier write_no_fpos.write_f;
      @@
      // write fops use offset
      struct file_operations fops = {
      ...
       .write = write_f,
       .read = read_f,
      ...
      +.llseek = noop_llseek, /* read and write both use no f_pos */
      };
      
      @ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier write_no_fpos.write_f;
      @@
      struct file_operations fops = {
      ... .write = write_f, ...
      +.llseek = noop_llseek, /* write uses no f_pos */
      };
      
      @ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      identifier read_no_fpos.read_f;
      @@
      struct file_operations fops = {
      ... .read = read_f, ...
      +.llseek = noop_llseek, /* read uses no f_pos */
      };
      
      @ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
      identifier fops0.fops;
      @@
      struct file_operations fops = {
      ...
      +.llseek = noop_llseek, /* no read or write fn */
      };
      ===== End semantic patch =====
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Julia Lawall <julia@diku.dk>
      Cc: Christoph Hellwig <hch@infradead.org>
      6038f373
  2. 06 9月, 2010 1 次提交
  3. 11 8月, 2010 1 次提交
  4. 28 7月, 2010 10 次提交
  5. 17 5月, 2010 8 次提交
  6. 02 5月, 2010 1 次提交
  7. 11 4月, 2010 2 次提交
  8. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  9. 28 3月, 2010 1 次提交
  10. 20 2月, 2010 5 次提交
  11. 18 2月, 2010 1 次提交
  12. 19 1月, 2010 3 次提交
  13. 18 1月, 2010 1 次提交
  14. 31 12月, 2009 2 次提交
  15. 10 12月, 2009 2 次提交
    • G
      [SCSI] qla2xxx: Queue depth ramp up/down modification changes. · c45dd305
      Giridhar Malavali 提交于
      Removed the module parameters ql2xqfulltracking and ql2xqfullrampup
      since the queue depth ramp up/down functionality is moved to scsi-ml.
      Signed-off-by: NGiridhar Malavali <giridhar.malavali@qlogic.com>
      Signed-off-by: NJames Bottomley <James.Bottomley@suse.de>
      c45dd305
    • M
      [SCSI] qla2xxx: dpc thread can execute before scsi host has been added · 1486400f
      Michael Reed 提交于
      Fix crash in qla2x00_fdmi_register() due to the dpc
      thread executing before the scsi host has been fully
      added.
      
      Unable to handle kernel NULL pointer dereference (address 00000000000001d0)
      qla2xxx_7_dpc[4140]: Oops 8813272891392 [1]
      
      Call Trace:
       [<a000000100016910>] show_stack+0x50/0xa0
                                      sp=e00000b07c59f930 bsp=e00000b07c591400
       [<a000000100017180>] show_regs+0x820/0x860
                                      sp=e00000b07c59fb00 bsp=e00000b07c5913a0
       [<a00000010003bd60>] die+0x1a0/0x2e0
                                      sp=e00000b07c59fb00 bsp=e00000b07c591360
       [<a0000001000681a0>] ia64_do_page_fault+0x8c0/0x9e0
                                      sp=e00000b07c59fb00 bsp=e00000b07c591310
       [<a00000010000c8e0>] ia64_native_leave_kernel+0x0/0x270
                                      sp=e00000b07c59fb90 bsp=e00000b07c591310
       [<a000000207197350>] qla2x00_fdmi_register+0x850/0xbe0 [qla2xxx]
                                      sp=e00000b07c59fd60 bsp=e00000b07c591290
       [<a000000207171570>] qla2x00_configure_loop+0x1930/0x34c0 [qla2xxx]
                                      sp=e00000b07c59fd60 bsp=e00000b07c591128
       [<a0000002071732b0>] qla2x00_loop_resync+0x1b0/0x2e0 [qla2xxx]
                                      sp=e00000b07c59fdf0 bsp=e00000b07c5910c0
       [<a000000207166d40>] qla2x00_do_dpc+0x9a0/0xce0 [qla2xxx]
                                      sp=e00000b07c59fdf0 bsp=e00000b07c590fa0
       [<a0000001000d5bb0>] kthread+0x110/0x140
                                      sp=e00000b07c59fe00 bsp=e00000b07c590f68
       [<a000000100014a30>] kernel_thread_helper+0xd0/0x100
                                      sp=e00000b07c59fe30 bsp=e00000b07c590f40
       [<a00000010000a4c0>] start_kernel_thread+0x20/0x40
                                      sp=e00000b07c59fe30 bsp=e00000b07c590f40
      
      crash> dis a000000207197350
      0xa000000207197350 <qla2x00_fdmi_register+2128>:        [MMI]       ld1 r45=[r14];;
      crash> scsi_qla_host.host 0xe00000b058c73ff8
        host = 0xe00000b058c73be0,
      crash> Scsi_Host.shost_data 0xe00000b058c73be0
        shost_data = 0x0,  <<<<<<<<<<<
      
      The fc_transport fc_* workqueue threads have yet to be created.
      
      crash> ps | grep _7
         3891      2   2  e00000b075c80000  IN   0.0       0      0  [scsi_eh_7]
         4140      2   3  e00000b07c590000  RU   0.0       0      0  [qla2xxx_7_dpc]
      
      The thread creating adding the Scsi_Host is blocked due to other
      activity in sysfs.
      
      crash> bt 3762
      PID: 3762   TASK: e00000b071e70000  CPU: 3   COMMAND: "modprobe"
       #0 [BSP:e00000b071e71548] schedule at a000000100727e00
       #1 [BSP:e00000b071e714c8] __mutex_lock_slowpath at a0000001007295a0
       #2 [BSP:e00000b071e714a8] mutex_lock at a000000100729830
       #3 [BSP:e00000b071e71478] sysfs_addrm_start at a0000001002584f0
       #4 [BSP:e00000b071e71440] create_dir at a000000100259350
       #5 [BSP:e00000b071e71410] sysfs_create_subdir at a000000100259510
       #6 [BSP:e00000b071e713b0] internal_create_group at a00000010025c880
       #7 [BSP:e00000b071e71388] sysfs_create_group at a00000010025cc50
       #8 [BSP:e00000b071e71368] dpm_sysfs_add at a000000100425050
       #9 [BSP:e00000b071e71310] device_add at a000000100417d90
      #10 [BSP:e00000b071e712d8] scsi_add_host at a00000010045a380
      #11 [BSP:e00000b071e71268] qla2x00_probe_one at a0000002071be950
      #12 [BSP:e00000b071e71248] local_pci_probe at a00000010032e490
      #13 [BSP:e00000b071e71218] pci_device_probe at a00000010032ecd0
      #14 [BSP:e00000b071e711d8] driver_probe_device at a00000010041d480
      #15 [BSP:e00000b071e711a8] __driver_attach at a00000010041d6e0
      #16 [BSP:e00000b071e71170] bus_for_each_dev at a00000010041c240
      #17 [BSP:e00000b071e71150] driver_attach at a00000010041d0a0
      #18 [BSP:e00000b071e71108] bus_add_driver at a00000010041b080
      #19 [BSP:e00000b071e710c0] driver_register at a00000010041dea0
      #20 [BSP:e00000b071e71088] __pci_register_driver at a00000010032f610
      #21 [BSP:e00000b071e71058] (unknown) at a000000207200270
      #22 [BSP:e00000b071e71018] do_one_initcall at a00000010000a9c0
      #23 [BSP:e00000b071e70f98] sys_init_module at a0000001000fef00
      #24 [BSP:e00000b071e70f98] ia64_ret_from_syscall at a00000010000c740
      
      So, it appears that qla2xxx dpc thread is moving forward before the
      scsi host has been completely added.
      
      This patch moves the setting of the init_done (and online) flag to
      after the call to scsi_add_host() to hold off the dpc thread.
      
      Found via large lun count testing using 2.6.31.
      Signed-off-by: NMichael Reed <mdr@sgi.com>
      Acked-by: NGiridhar Malavali <giridhar.malavali@qlogic.com>
      Cc: stable@kernel.org
      Signed-off-by: NJames Bottomley <James.Bottomley@suse.de>
      1486400f