1. 10 Feb, 2021 1 commit
    • Andreas Gruenbacher's avatar
      gfs2: Recursive gfs2_quota_hold in gfs2_iomap_end · 7009fa9c
      Andreas Gruenbacher authored
      When starting an iomap write, gfs2_quota_lock_check -> gfs2_quota_lock
      -> gfs2_quota_hold is called from gfs2_iomap_begin.  At the end of the
      write, before unlocking the quotas, punch_hole -> gfs2_quota_hold can be
      called again in gfs2_iomap_end, which is incorrect and leads to a failed
      assertion.  Instead, move the call to gfs2_quota_unlock before the call
      to punch_hole to fix that.
      
      Fixes: 64bc06bb ("gfs2: iomap buffered write support")
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      7009fa9c
  2. 08 Feb, 2021 2 commits
    • Andreas Gruenbacher's avatar
      gfs2: Add trusted xattr support · 866eef48
      Andreas Gruenbacher authored
      Add support for an additional filesystem version (sb_fs_format = 1802).
      When a filesystem with the new version is mounted, the filesystem
      supports "trusted.*" xattrs.
      
      In addition, version 1802 filesystems implement a form of forward
      compatibility for xattrs: when xattrs with an unknown prefix (ea_type)
      are found on a version 1802 filesystem, those attributes are not shown
      by listxattr, and they are not accessible by getxattr, setxattr, or
      removexattr.
      
      This mechanism might turn out to be what we need in the future, but if
      not, we can always bump the filesystem version and break compatibility
      instead.
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      Signed-off-by: default avatarAndrew Price <anprice@redhat.com>
      866eef48
    • Andrew Price's avatar
      gfs2: Enable rgrplvb for sb_fs_format 1802 · 47b7ec1d
      Andrew Price authored
      Turn on rgrplvb by default for sb_fs_format > 1801.
      
      Mount options still have to override this so a new args field to
      differentiate between 'off' and 'not specified' is added, and the new
      default is applied only when it's not specified.
      Signed-off-by: default avatarAndrew Price <anprice@redhat.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      47b7ec1d
  3. 05 Feb, 2021 2 commits
    • Bob Peterson's avatar
      gfs2: Don't skip dlm unlock if glock has an lvb · 78178ca8
      Bob Peterson authored
      Patch fb6791d1 was designed to allow gfs2 to unmount quicker by
      skipping the step where it tells dlm to unlock glocks in EX with lvbs.
      This was done because when gfs2 unmounts a file system, it destroys the
      dlm lockspace shortly after it destroys the glocks so it doesn't need to
      unlock them all: the unlock is implied when the lockspace is destroyed
      by dlm.
      
      However, that patch introduced a use-after-free in dlm: as part of its
      normal dlm_recoverd process, it can call ls_recovery to recover dead
      locks. In so doing, it can call recover_rsbs which calls recover_lvb for
      any mastered rsbs. Func recover_lvb runs through the list of lkbs queued
      to the given rsb (if the glock is cached but unlocked, it will still be
      queued to the lkb, but in NL--Unlocked--mode) and if it has an lvb,
      copies it to the rsb, thus trying to preserve the lkb. However, when
      gfs2 skips the dlm unlock step, it frees the glock and its lvb, which
      means dlm's function recover_lvb references the now freed lvb pointer,
      copying the freed lvb memory to the rsb.
      
      This patch changes the check in gdlm_put_lock so that it calls
      dlm_unlock for all glocks that contain an lvb pointer.
      
      Fixes: fb6791d1 ("GFS2: skip dlm_unlock calls in unmount")
      Cc: stable@vger.kernel.org # v3.8+
      Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      78178ca8
    • Andreas Gruenbacher's avatar
      gfs2: Lock imbalance on error path in gfs2_recover_one · 834ec3e1
      Andreas Gruenbacher authored
      In gfs2_recover_one, fix a sd_log_flush_lock imbalance when a recovery
      pass fails.
      
      Fixes: c9ebc4b7 ("gfs2: allow journal replay to hold sd_log_flush_lock")
      Cc: stable@vger.kernel.org # v5.7+
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      834ec3e1
  4. 25 Jan, 2021 4 commits
  5. 22 Jan, 2021 1 commit
  6. 31 Dec, 2020 1 commit
  7. 22 Dec, 2020 2 commits
    • Bob Peterson's avatar
      gfs2: move freeze glock outside the make_fs_rw and _ro functions · 96b1454f
      Bob Peterson authored
      Before this patch, sister functions gfs2_make_fs_rw and gfs2_make_fs_ro locked
      (held) the freeze glock by calling gfs2_freeze_lock and gfs2_freeze_unlock.
      The problem is, not all the callers of gfs2_make_fs_ro should be doing this.
      The three callers of gfs2_make_fs_ro are: remount (gfs2_reconfigure),
      signal_our_withdraw, and unmount (gfs2_put_super). But when unmounting the
      file system we can get into the following circular lock dependency:
      
      deactivate_super
         down_write(&s->s_umount); <-------------------------------------- s_umount
         deactivate_locked_super
            gfs2_kill_sb
               kill_block_super
                  generic_shutdown_super
                     gfs2_put_super
                        gfs2_make_fs_ro
                           gfs2_glock_nq_init sd_freeze_gl
                              freeze_go_sync
                                 if (freeze glock in SH)
                                    freeze_super (vfs)
                                       down_write(&sb->s_umount); <------- s_umount
      
      This patch moves the hold of the freeze glock outside the two sister rw/ro
      functions to their callers, but it doesn't request the glock from
      gfs2_put_super, thus eliminating the circular dependency.
      Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      96b1454f
    • Bob Peterson's avatar
      gfs2: Add common helper for holding and releasing the freeze glock · c77b52c0
      Bob Peterson authored
      Many places in the gfs2 code queued and dequeued the freeze glock.
      Almost all of them acquire it in SHARED mode, and need to specify the
      same LM_FLAG_NOEXP and GL_EXACT flags.
      
      This patch adds common helper functions gfs2_freeze_lock and gfs2_freeze_unlock
      to make the code more readable, and to prepare for the next patch.
      Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      c77b52c0
  8. 20 Dec, 2020 2 commits
  9. 19 Dec, 2020 25 commits