1. 06 Nov, 2015 1 commit
  2. 05 May, 2015 2 commits
  3. 18 Mar, 2015 1 commit
  4. 03 Jul, 2013 1 commit
  5. 07 May, 2013 1 commit
  6. 09 Apr, 2013 1 commit
    • Al Viro's avatar
      procfs: new helper - PDE_DATA(inode) · d9dda78b
      Al Viro authored
      The only part of proc_dir_entry the code outside of fs/proc
      really cares about is PDE(inode)->data.  Provide a helper
      for that; static inline for now, eventually will be moved
      to fs/proc, along with the knowledge of struct proc_dir_entry
      layout.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      d9dda78b
  7. 08 Nov, 2011 1 commit
  8. 15 Oct, 2010 1 commit
    • Arnd Bergmann's avatar
      llseek: automatically add .llseek fop · 6038f373
      Arnd Bergmann authored
      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: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Julia Lawall <julia@diku.dk>
      Cc: Christoph Hellwig <hch@infradead.org>
      6038f373
  9. 05 Oct, 2010 1 commit
    • Arnd Bergmann's avatar
      block: autoconvert trivial BKL users to private mutex · 2a48fc0a
      Arnd Bergmann authored
      The block device drivers have all gained new lock_kernel
      calls from a recent pushdown, and some of the drivers
      were already using the BKL before.
      
      This turns the BKL into a set of per-driver mutexes.
      Still need to check whether this is safe to do.
      
      file=$1
      name=$2
      if grep -q lock_kernel ${file} ; then
          if grep -q 'include.*linux.mutex.h' ${file} ; then
                  sed -i '/include.*<linux\/smp_lock.h>/d' ${file}
          else
                  sed -i 's/include.*<linux\/smp_lock.h>.*$/include <linux\/mutex.h>/g' ${file}
          fi
          sed -i ${file} \
              -e "/^#include.*linux.mutex.h/,$ {
                      1,/^\(static\|int\|long\)/ {
                           /^\(static\|int\|long\)/istatic DEFINE_MUTEX(${name}_mutex);
      
      } }"  \
          -e "s/\(un\)*lock_kernel\>[ ]*()/mutex_\1lock(\&${name}_mutex)/g" \
          -e '/[      ]*cycle_kernel_lock();/d'
      else
          sed -i -e '/include.*\<smp_lock.h\>/d' ${file}  \
                      -e '/cycle_kernel_lock()/d'
      fi
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      2a48fc0a
  10. 07 Aug, 2010 3 commits
  11. 12 Jan, 2010 1 commit
  12. 29 Oct, 2009 1 commit
  13. 22 Sep, 2009 1 commit
  14. 01 Sep, 2009 1 commit
  15. 07 Aug, 2009 3 commits
    • Borislav Petkov's avatar
      ide-tape: fix handling of postponed rqs · 6f3848ac
      Borislav Petkov authored
      ide-tape used to hit
      
      [   58.614854] ide-tape: ht0: BUG: Two DSC requests queued!
      
      due to the fact that another rq was being issued while the driver was
      waiting for DSC to get set for the device executing ATAPI commands which
      set the DSC to 1 to indicate completion.
      
      Here's a sample output of that case:
      
      issue REZERO_UNIT
      
      [  143.088505] ide-tape: ide_tape_issue_pc: retry #0, cmd: 0x01
      [  143.095122] ide: Enter ide_pc_intr - interrupt handler
      [  143.096118] ide: Packet command completed, 0 bytes transferred
      [  143.106319] ide-tape: ide_tape_callback: cmd: 0x1, dsc: 1, err: 0
      [  143.112601] ide-tape: idetape_postpone_request: cmd: 0x1, dsc_poll_freq: 2000
      
      we stall the ide-tape queue here waiting for DSC
      
      [  143.119936] ide-tape: ide_tape_read_position: enter
      [  145.119019] ide-tape: idetape_do_request: sector: 4294967295, nr_sectors: 0
      
      and issue the new READ_POSITION rq and hit the check.
      
      [  145.126247] ide-tape: ht0: BUG: Two DSC requests queued!
      [  145.131748] ide-tape: ide_tape_read_position: BOP - No
      [  145.137059] ide-tape: ide_tape_read_position: EOP - No
      
      Also, ->postponed_rq used to point to that postponed request. To make
      things worse, in certain circumstances the rq it was pointing to got
      replaced unterneath it by swiftly reusing the same rq from the mempool
      of the block layer practically confusing stuff even more.
      
      However, we don't need to keep a pointer to that rq but simply wait for
      DSC to be set first before issuing the follow-up request in the drive's
      queue. In order to do that, we make idetape_do_request() first check the
      DSC and if not set, we stall the drive queue giving the other device on
      that IDE channel a chance.
      Signed-off-by: default avatarBorislav Petkov <petkovbb@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6f3848ac
    • Borislav Petkov's avatar
      ide-tape: convert to ide_debug_log macro · e972d702
      Borislav Petkov authored
      Remove tape->debug_mask and use drive->debug_mask instead.
      
      There should be no functional change resulting from this patch.
      Signed-off-by: default avatarBorislav Petkov <petkovbb@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e972d702
    • Mark de Wever's avatar
      ide-tape: fix debug call · 37bbe084
      Mark de Wever authored
      This error only occurs when IDETAPE_DEBUG_LOG is enabled.
      Signed-off-by: default avatarMark de Wever <koraq@xs4all.nl>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      37bbe084
  16. 21 Jul, 2009 1 commit
  17. 15 Jun, 2009 2 commits
  18. 08 Jun, 2009 1 commit
    • Borislav Petkov's avatar
      ide-tape: fix proc warning · 9d01e4cd
      Borislav Petkov authored
      ide_tape_chrdev_get() was missing an ide_device_get() refcount increment
      which lead to the following warning:
      
      [  278.147906] ------------[ cut here ]------------
      [  278.152685] WARNING: at fs/proc/generic.c:847 remove_proc_entry+0x199/0x1b8()
      [  278.160070] Hardware name: P4I45PE    1.00
      [  278.160076] remove_proc_entry: removing non-empty directory 'ide0/hdb', leaking at least 'name'
      [  278.160080] Modules linked in: rtc intel_agp pcspkr thermal processor thermal_sys parport_pc parport agpgart button
      [  278.160100] Pid: 2312, comm: mt Not tainted 2.6.30-rc2 #3
      [  278.160105] Call Trace:
      [  278.160117]  [<c012141d>] warn_slowpath+0x71/0xa0
      [  278.160126]  [<c035f219>] ? _spin_unlock_irqrestore+0x29/0x2c
      [  278.160132]  [<c011c686>] ? try_to_wake_up+0x1b6/0x1c0
      [  278.160141]  [<c011c69b>] ? default_wake_function+0xb/0xd
      [  278.160149]  [<c0177ead>] ? pollwake+0x4a/0x55
      [  278.160156]  [<c035f240>] ? _spin_unlock+0x24/0x26
      [  278.160163]  [<c0165d38>] ? add_partial+0x44/0x49
      [  278.160169]  [<c01669e8>] ? __slab_free+0xba/0x29c
      [  278.160177]  [<c01a13d8>] ? sysfs_delete_inode+0x0/0x3c
      [  278.160184]  [<c019ca92>] remove_proc_entry+0x199/0x1b8
      [  278.160191]  [<c01a297e>] ? remove_dir+0x27/0x2e
      [  278.160199]  [<c025f3ab>] ide_proc_unregister_device+0x40/0x4c
      [  278.160207]  [<c02599cd>] drive_release_dev+0x14/0x47
      [  278.160214]  [<c0250538>] device_release+0x35/0x5a
      [  278.160221]  [<c01f8bed>] kobject_release+0x40/0x50
      [  278.160226]  [<c01f8bad>] ? kobject_release+0x0/0x50
      [  278.160232]  [<c01f96ac>] kref_put+0x3c/0x4a
      [  278.160238]  [<c01f8b29>] kobject_put+0x37/0x3c
      [  278.160243]  [<c025020c>] put_device+0xf/0x11
      [  278.160249]  [<c025789f>] ide_device_put+0x2d/0x30
      [  278.160255]  [<c02658da>] ide_tape_put+0x24/0x32
      [  278.160261]  [<c0266e0c>] idetape_chrdev_release+0x17f/0x18e
      [  278.160269]  [<c016c4f5>] __fput+0xca/0x175
      [  278.160275]  [<c016c5b9>] fput+0x19/0x1b
      [  278.160280]  [<c0169d19>] filp_close+0x51/0x5b
      [  278.160286]  [<c0169d96>] sys_close+0x73/0xad
      [  278.160293]  [<c0102a61>] syscall_call+0x7/0xb
      [  278.160298] ---[ end trace f16d907ea1f89336 ]---
      
      Instead of trivially fixing it by adding the missing call,
      ide_tape_chrdev_get() and ide_tape_get() were merged into one function
      since both were almost identical. The only difference was that
      ide_tape_chrdev_get() was accessing the ide-tape reference through the
      idetape_devs[] array of minors instead of through the gendisk.
      
      Accomodate that by adding two additional parameters to ide_tape_get() to
      annotate the call site and invoke the proper behavior.
      
      As a result, remove ide_tape_chrdev_get().
      Signed-off-by: default avatarBorislav Petkov <petkovbb@gmail.com>
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
      9d01e4cd
  19. 07 Jun, 2009 2 commits
  20. 19 May, 2009 1 commit
    • Tejun Heo's avatar
      block: set rq->resid_len to blk_rq_bytes() on issue · 5f49f631
      Tejun Heo authored
      In commit c3a4d78c, while introducing
      rq->resid_len, the default value of residue count was changed from
      full count to zero.  The conversion was done under the assumption that
      when a request fails residue count wasn't defined.  However, Boaz and
      James pointed out that this wasn't true and the residue count should
      be preserved for failed requests too.
      
      This patchset restores the original behavior by setting rq->resid_len
      to blk_rq_bytes(rq) on request start and restoring explicit clearing
      in affected drivers.  While at it, take advantage of the fact that
      rq->resid_len is set to full count where applicable.
      
      * ide-cd: rq->resid_len cleared on pc success
      
      * mptsas: req->resid_len cleared on success
      
      * sas_expander: rsp/req->resid_len cleared on success
      
      * mpt2sas_transport: req->resid_len cleared on success
      
      * ide-cd, ide-tape, mptsas, sas_host_smp, mpt2sas_transport, ub: take
        advantage of initial full count to simplify code
      
      Boaz Harrosh spotted bug in resid_len initialization.  Fixed as
      suggested.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Acked-by: default avatarBorislav Petkov <petkovbb@googlemail.com>
      Cc: Boaz Harrosh <bharrosh@panasas.com>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Pete Zaitcev <zaitcev@redhat.com>
      Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
      Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
      Cc: Eric Moore <Eric.Moore@lsi.com>
      Cc: Darrick J. Wong <djwong@us.ibm.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      5f49f631
  21. 17 May, 2009 1 commit
  22. 16 May, 2009 1 commit
  23. 14 May, 2009 9 commits
  24. 11 May, 2009 2 commits