1. 20 3月, 2019 1 次提交
    • I
      libceph: wait for latest osdmap in ceph_monc_blacklist_add() · bb229bbb
      Ilya Dryomov 提交于
      Because map updates are distributed lazily, an OSD may not know about
      the new blacklist for quite some time after "osd blacklist add" command
      is completed.  This makes it possible for a blacklisted but still alive
      client to overwrite a post-blacklist update, resulting in data
      corruption.
      
      Waiting for latest osdmap in ceph_monc_blacklist_add() and thus using
      the post-blacklist epoch for all post-blacklist requests ensures that
      all such requests "wait" for the blacklist to come into force on their
      respective OSDs.
      
      Cc: stable@vger.kernel.org
      Fixes: 6305a3b4 ("libceph: support for blacklisting clients")
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      Reviewed-by: NJason Dillaman <dillaman@redhat.com>
      bb229bbb
  2. 03 8月, 2018 1 次提交
  3. 07 6月, 2018 1 次提交
    • K
      treewide: Use struct_size() for kmalloc()-family · acafe7e3
      Kees Cook 提交于
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          void *entry[];
      };
      
      instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);
      
      This patch makes the changes for kmalloc()-family (and kvmalloc()-family)
      uses. It was done via automatic conversion with manual review for the
      "CHECKME" non-standard cases noted below, using the following Coccinelle
      script:
      
      // pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
      //                      sizeof *pkey_cache->table, GFP_KERNEL);
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      identifier VAR, ELEMENT;
      expression COUNT;
      @@
      
      - alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
      + alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
      
      // mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      identifier VAR, ELEMENT;
      expression COUNT;
      @@
      
      - alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
      + alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
      
      // Same pattern, but can't trivially locate the trailing element name,
      // or variable name.
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      expression SOMETHING, COUNT, ELEMENT;
      @@
      
      - alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
      + alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)
      Signed-off-by: NKees Cook <keescook@chromium.org>
      acafe7e3
  4. 24 4月, 2018 2 次提交
    • I
      libceph: reschedule a tick in finish_hunting() · 7b4c443d
      Ilya Dryomov 提交于
      If we go without an established session for a while, backoff delay will
      climb to 30 seconds.  The keepalive timeout is also 30 seconds, so it's
      pretty easily hit after a prolonged hunting for a monitor: we don't get
      a chance to send out a keepalive in time, which means we never get back
      a keepalive ack in time, cutting an established session and attempting
      to connect to a different monitor every 30 seconds:
      
        [Sun Apr 1 23:37:05 2018] libceph: mon0 10.80.20.99:6789 session established
        [Sun Apr 1 23:37:36 2018] libceph: mon0 10.80.20.99:6789 session lost, hunting for new mon
        [Sun Apr 1 23:37:36 2018] libceph: mon2 10.80.20.103:6789 session established
        [Sun Apr 1 23:38:07 2018] libceph: mon2 10.80.20.103:6789 session lost, hunting for new mon
        [Sun Apr 1 23:38:07 2018] libceph: mon1 10.80.20.100:6789 session established
        [Sun Apr 1 23:38:37 2018] libceph: mon1 10.80.20.100:6789 session lost, hunting for new mon
        [Sun Apr 1 23:38:37 2018] libceph: mon2 10.80.20.103:6789 session established
        [Sun Apr 1 23:39:08 2018] libceph: mon2 10.80.20.103:6789 session lost, hunting for new mon
      
      The regular keepalive interval is 10 seconds.  After ->hunting is
      cleared in finish_hunting(), call __schedule_delayed() to ensure we
      send out a keepalive after 10 seconds.
      
      Cc: stable@vger.kernel.org # 4.7+
      Link: http://tracker.ceph.com/issues/23537Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      Reviewed-by: NJason Dillaman <dillaman@redhat.com>
      7b4c443d
    • I
      libceph: un-backoff on tick when we have a authenticated session · facb9f6e
      Ilya Dryomov 提交于
      This means that if we do some backoff, then authenticate, and are
      healthy for an extended period of time, a subsequent failure won't
      leave us starting our hunting sequence with a large backoff.
      
      Mirrors ceph.git commit d466bc6e66abba9b464b0b69687cf45c9dccf383.
      
      Cc: stable@vger.kernel.org # 4.7+
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      Reviewed-by: NJason Dillaman <dillaman@redhat.com>
      facb9f6e
  5. 02 4月, 2018 1 次提交
  6. 13 11月, 2017 1 次提交
  7. 02 11月, 2017 1 次提交
    • G
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman 提交于
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: NKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: NPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  8. 07 9月, 2017 1 次提交
  9. 07 7月, 2017 1 次提交
  10. 24 5月, 2017 1 次提交
  11. 13 12月, 2016 1 次提交
  12. 25 8月, 2016 1 次提交
  13. 09 8月, 2016 1 次提交
  14. 28 7月, 2016 1 次提交
  15. 26 5月, 2016 6 次提交
  16. 26 3月, 2016 9 次提交
    • I
      libceph: behave in mon_fault() if cur_mon < 0 · b5d91704
      Ilya Dryomov 提交于
      This can happen if __close_session() in ceph_monc_stop() races with
      a connection reset.  We need to ignore such faults, otherwise it's
      likely we would take !hunting, call __schedule_delayed() and end up
      with delayed_work() executing on invalid memory, among other things.
      
      The (two!) con->private tests are useless, as nothing ever clears
      con->private.  Nuke them.
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      b5d91704
    • I
      libceph: reschedule tick in mon_fault() · bee3a37c
      Ilya Dryomov 提交于
      Doing __schedule_delayed() in the hunting branch is pointless, as the
      tick will have already been scheduled by then.
      
      What we need to do instead is *reschedule* it in the !hunting branch,
      after reopen_session() changes hunt_mult, which affects the delay.
      This helps with spacing out connection attempts and avoiding things
      like two back-to-back attempts followed by a longer period of waiting
      around.
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      bee3a37c
    • I
      libceph: introduce and switch to reopen_session() · 1752b50c
      Ilya Dryomov 提交于
      hunting is now set in __open_session() and cleared in finish_hunting(),
      instead of all around.  The "session lost" message is printed not only
      on connection resets, but also on keepalive timeouts.
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      1752b50c
    • I
      libceph: monc hunt rate is 3s with backoff up to 30s · 168b9090
      Ilya Dryomov 提交于
      Unless we are in the process of setting up a client (i.e. connecting to
      the monitor cluster for the first time), apply a backoff: every time we
      want to reopen a session, increase our timeout by a multiple (currently
      2); when we complete the connection, reduce that multipler by 50%.
      
      Mirrors ceph.git commit 794c86fd289bd62a35ed14368fa096c46736e9a2.
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      168b9090
    • I
      libceph: monc ping rate is 10s · 58d81b12
      Ilya Dryomov 提交于
      Split ping interval and ping timeout: ping interval is 10s; keepalive
      timeout is 30s.
      
      Make monc_ping_timeout a constant while at it - it's not actually
      exported as a mount option (and the rest of tick-related settings won't
      be either), so it's got no place in ceph_options.
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      58d81b12
    • I
      libceph: pick a different monitor when reconnecting · 0e04dc26
      Ilya Dryomov 提交于
      Don't try to reconnect to the same monitor when we fail to establish
      a session within a timeout or it's lost.
      
      For that, pick_new_mon() needs to see the old value of cur_mon, so
      don't clear it in __close_session() - all calls to __close_session()
      but one are followed by __open_session() anyway.  __open_session() is
      only called when a new session needs to be established, so the "already
      open?" branch, which is now in the way, is simply dropped.
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      0e04dc26
    • I
      libceph: revamp subs code, switch to SUBSCRIBE2 protocol · 82dcabad
      Ilya Dryomov 提交于
      It is currently hard-coded in the mon_client that mdsmap and monmap
      subs are continuous, while osdmap sub is always "onetime".  To better
      handle full clusters/pools in the osd_client, we need to be able to
      issue continuous osdmap subs.  Revamp subs code to allow us to specify
      for each sub whether it should be continuous or not.
      
      Although not strictly required for the above, switch to SUBSCRIBE2
      protocol while at it, eliminating the ambiguity between a request for
      "every map since X" and a request for "just the latest" when we don't
      have a map yet (i.e. have epoch 0).  SUBSCRIBE2 feature bit is now
      required - it's been supported since pre-argonaut (2010).
      
      Move "got mdsmap" call to the end of ceph_mdsc_handle_map() - calling
      in before we validate the epoch and successfully install the new map
      can mess up mon_client sub state.
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      82dcabad
    • I
      libceph: decouple hunting and subs management · 0f9af169
      Ilya Dryomov 提交于
      Coupling hunting state with subscribe state is not a good idea.  Clear
      hunting when we complete the authentication handshake.
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      0f9af169
    • I
      libceph: move debugfs initialization into __ceph_open_session() · 02ac956c
      Ilya Dryomov 提交于
      Our debugfs dir name is a concatenation of cluster fsid and client
      unique ID ("global_id").  It used to be the case that we learned
      global_id first, nowadays we always learn fsid first - the monmap is
      sent before any auth replies are.  ceph_debugfs_client_init() call in
      ceph_monc_handle_map() is therefore never executed and can be removed.
      
      Its counterpart in handle_auth_reply() doesn't really belong there
      either: having to do monc->client and unlocking early to work around
      lockdep is a testament to that.  Move it into __ceph_open_session(),
      where it can be called unconditionally.
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      02ac956c
  17. 22 1月, 2016 1 次提交
  18. 09 9月, 2015 1 次提交
  19. 25 6月, 2015 2 次提交
    • I
      libceph: a couple tweaks for wait loops · 216639dd
      Ilya Dryomov 提交于
      - return -ETIMEDOUT instead of -EIO in case of timeout
      - wait_event_interruptible_timeout() returns time left until timeout
        and since it can be almost LONG_MAX we had better assign it to long
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      Reviewed-by: NAlex Elder <elder@linaro.org>
      216639dd
    • I
      libceph: store timeouts in jiffies, verify user input · a319bf56
      Ilya Dryomov 提交于
      There are currently three libceph-level timeouts that the user can
      specify on mount: mount_timeout, osd_idle_ttl and osdkeepalive.  All of
      these are in seconds and no checking is done on user input: negative
      values are accepted, we multiply them all by HZ which may or may not
      overflow, arbitrarily large jiffies then get added together, etc.
      
      There is also a bug in the way mount_timeout=0 is handled.  It's
      supposed to mean "infinite timeout", but that's not how wait.h APIs
      treat it and so __ceph_open_session() for example will busy loop
      without much chance of being interrupted if none of ceph-mons are
      there.
      
      Fix all this by verifying user input, storing timeouts capped by
      msecs_to_jiffies() in jiffies and using the new ceph_timeout_jiffies()
      helper for all user-specified waits to handle infinite timeouts
      correctly.
      Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
      Reviewed-by: NAlex Elder <elder@linaro.org>
      a319bf56
  20. 19 2月, 2015 2 次提交
  21. 09 1月, 2015 1 次提交
  22. 15 10月, 2014 1 次提交
  23. 11 9月, 2014 1 次提交
  24. 06 6月, 2014 1 次提交