Commit c02be233 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'xfs-4.16-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux

Pull xfs fixes from Darrick Wong:

 - fix some compiler warnings

 - fix block reservations for transactions created during log recovery

 - fix resource leaks when respecifying mount options

* tag 'xfs-4.16-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  xfs: fix potential memory leak in mount option parsing
  xfs: reserve blocks for refcount / rmap log item recovery
  xfs: use memset to initialize xfs_scrub_agfl_info
parents b1aad682 5b4c845e
...@@ -767,7 +767,7 @@ int ...@@ -767,7 +767,7 @@ int
xfs_scrub_agfl( xfs_scrub_agfl(
struct xfs_scrub_context *sc) struct xfs_scrub_context *sc)
{ {
struct xfs_scrub_agfl_info sai = { 0 }; struct xfs_scrub_agfl_info sai;
struct xfs_agf *agf; struct xfs_agf *agf;
xfs_agnumber_t agno; xfs_agnumber_t agno;
unsigned int agflcount; unsigned int agflcount;
...@@ -795,6 +795,7 @@ xfs_scrub_agfl( ...@@ -795,6 +795,7 @@ xfs_scrub_agfl(
xfs_scrub_block_set_corrupt(sc, sc->sa.agf_bp); xfs_scrub_block_set_corrupt(sc, sc->sa.agf_bp);
goto out; goto out;
} }
memset(&sai, 0, sizeof(sai));
sai.sz_entries = agflcount; sai.sz_entries = agflcount;
sai.entries = kmem_zalloc(sizeof(xfs_agblock_t) * agflcount, KM_NOFS); sai.entries = kmem_zalloc(sizeof(xfs_agblock_t) * agflcount, KM_NOFS);
if (!sai.entries) { if (!sai.entries) {
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_shared.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_defer.h" #include "xfs_defer.h"
#include "xfs_trans.h" #include "xfs_trans.h"
...@@ -456,10 +457,12 @@ xfs_cui_recover( ...@@ -456,10 +457,12 @@ xfs_cui_recover(
* transaction. Normally, any work that needs to be deferred * transaction. Normally, any work that needs to be deferred
* gets attached to the same defer_ops that scheduled the * gets attached to the same defer_ops that scheduled the
* refcount update. However, we're in log recovery here, so we * refcount update. However, we're in log recovery here, so we
* we create our own defer_ops and use that to finish up any * we use the passed in defer_ops and to finish up any work that
* work that doesn't fit. * doesn't fit. We need to reserve enough blocks to handle a
* full btree split on either end of the refcount range.
*/ */
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
mp->m_refc_maxlevels * 2, 0, XFS_TRANS_RESERVE, &tp);
if (error) if (error)
return error; return error;
cudp = xfs_trans_get_cud(tp, cuip); cudp = xfs_trans_get_cud(tp, cuip);
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "xfs_log_format.h" #include "xfs_log_format.h"
#include "xfs_trans_resv.h" #include "xfs_trans_resv.h"
#include "xfs_bit.h" #include "xfs_bit.h"
#include "xfs_shared.h"
#include "xfs_mount.h" #include "xfs_mount.h"
#include "xfs_defer.h" #include "xfs_defer.h"
#include "xfs_trans.h" #include "xfs_trans.h"
...@@ -470,7 +471,8 @@ xfs_rui_recover( ...@@ -470,7 +471,8 @@ xfs_rui_recover(
} }
} }
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
mp->m_rmap_maxlevels, 0, XFS_TRANS_RESERVE, &tp);
if (error) if (error)
return error; return error;
rudp = xfs_trans_get_rud(tp, ruip); rudp = xfs_trans_get_rud(tp, ruip);
......
...@@ -250,6 +250,7 @@ xfs_parseargs( ...@@ -250,6 +250,7 @@ xfs_parseargs(
return -EINVAL; return -EINVAL;
break; break;
case Opt_logdev: case Opt_logdev:
kfree(mp->m_logname);
mp->m_logname = match_strdup(args); mp->m_logname = match_strdup(args);
if (!mp->m_logname) if (!mp->m_logname)
return -ENOMEM; return -ENOMEM;
...@@ -258,6 +259,7 @@ xfs_parseargs( ...@@ -258,6 +259,7 @@ xfs_parseargs(
xfs_warn(mp, "%s option not allowed on this system", p); xfs_warn(mp, "%s option not allowed on this system", p);
return -EINVAL; return -EINVAL;
case Opt_rtdev: case Opt_rtdev:
kfree(mp->m_rtname);
mp->m_rtname = match_strdup(args); mp->m_rtname = match_strdup(args);
if (!mp->m_rtname) if (!mp->m_rtname)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment