Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add asyncreclaim mount option

Enable it only for ZFS by default
  • Loading branch information...
commit b1b0e337cd488d6ea2678af265130359388eda6b 1 parent eb57fd4
@glk authored
View
1  sys/fs/pefs/pefs.h
@@ -113,6 +113,7 @@ struct pefs_node {
#define PM_ROOT_CANRECURSE 0x01
#define PM_DIRCACHE 0x02
+#define PM_ASYNCRECLAIM 0x04
struct pefs_mount {
struct mount *pm_lowervfs;
View
6 sys/fs/pefs/pefs_subr.c
@@ -492,14 +492,18 @@ pefs_node_free_proc(void *context __unused, int pending __unused)
void
pefs_node_asyncfree(struct pefs_node *pn)
{
+ int flags;
+
PEFSDEBUG("pefs_node_asyncfree: free node %p\n", pn);
pefs_key_release(pn->pn_tkey.ptk_key);
pefs_dircache_free(pn->pn_dircache);
mtx_lock(&pefs_node_listmtx);
pefs_nodes--;
LIST_REMOVE(pn, pn_listentry);
+ flags = VFS_TO_PEFS(PN_TO_VP(pn)->v_mount)->pm_flags;
/* XXX Find a better way to check for safe context */
- if (memcmp(curthread->td_name, "vnlru", 6) == 0) {
+ if ((flags & PM_ASYNCRECLAIM) == 0 ||
+ memcmp(curthread->td_name, "vnlru", 6) == 0) {
mtx_unlock(&pefs_node_listmtx);
pefs_node_free(pn);
return;
View
64 sys/fs/pefs/pefs_vfsops.c
@@ -47,9 +47,23 @@ __FBSDID("$FreeBSD$");
#include <fs/pefs/pefs.h>
-static const char *pefs_dircache_support[] = {
- "zfs",
- NULL
+struct pefs_opt_descr {
+ char *fs;
+ int initial;
+ int forbid;
+};
+
+static const struct pefs_opt_descr pefs_opt_support[] = {
+ {
+ .fs = "zfs",
+ .initial = PM_DIRCACHE | PM_ASYNCRECLAIM,
+ .forbid = 0
+ },
+ { /* default flags */
+ .fs = NULL,
+ .initial = 0,
+ .forbid = PM_DIRCACHE,
+ }
};
static const char *pefs_opts[] = {
@@ -57,35 +71,37 @@ static const char *pefs_opts[] = {
"export",
"dircache",
"nodircache",
+ "asyncreclaim",
NULL
};
static MALLOC_DEFINE(M_PEFSMNT, "pefs_mount", "PEFS mount structure");
static void
-dircache_init(struct mount *mp, int opt, struct pefs_mount *pm)
+pefs_opt_set(struct mount *mp, int opt, struct pefs_mount *pm,
+ int flag, const char *flagname)
{
+ const struct pefs_opt_descr *descr;
char *lowerfs;
- int support;
lowerfs = mp->mnt_vnodecovered->v_mount->mnt_vfc->vfc_name;
- for (support = 0; pefs_dircache_support[support] != NULL; support++)
- if (strcmp(lowerfs, pefs_dircache_support[support]) == 0)
+ for (descr = pefs_opt_support; descr->fs != NULL; descr++)
+ if (strcmp(lowerfs, descr->fs) == 0)
break;
- support = pefs_dircache_support[support] != NULL ? 1 : 0;
if (opt < 0)
- opt = support;
- else if (opt > 0 && support == 0) {
- printf("pefs: dircache is not supported by file system: %s\n",
- lowerfs);
+ opt = descr->initial & flag;
+ else if (opt > 0 && (descr->forbid & flag) != 0) {
+ printf("pefs: %s is not supported by file system: %s\n",
+ flagname, lowerfs);
opt = 0;
}
if (opt == 0)
- pm->pm_flags &= ~PM_DIRCACHE;
+ pm->pm_flags &= ~flag;
else
- pm->pm_flags |= PM_DIRCACHE;
- PEFSDEBUG("pefs_mount: dircache %s\n", (opt ? "enabled" : "disabed"));
+ pm->pm_flags |= flag;
+ PEFSDEBUG("pefs_mount: %s %s\n",
+ flagname, (opt ? "enabled" : "disabed"));
}
static int
@@ -115,7 +131,7 @@ pefs_mount(struct mount *mp)
struct pefs_mount *pm;
char *from, *from_free;
int isvnunlocked = 0, len;
- int opt_dircache;
+ int opt_dircache, opt_asyncreclaim;
int error = 0;
PEFSDEBUG("pefs_mount(mp = %p)\n", (void *)mp);
@@ -134,13 +150,24 @@ pefs_mount(struct mount *mp)
vfs_deleteopt(mp->mnt_optnew, "nodircache");
opt_dircache = 0;
}
+ opt_asyncreclaim = -1;
+ if (vfs_flagopt(mp->mnt_optnew, "asyncreclaim", NULL, 0)) {
+ vfs_deleteopt(mp->mnt_optnew, "asyncreclaim");
+ opt_asyncreclaim = 1;
+ }
if (mp->mnt_flag & MNT_UPDATE) {
error = EOPNOTSUPP;
if (vfs_flagopt(mp->mnt_optnew, "export", NULL, 0))
error = 0;
if (opt_dircache >= 0) {
- dircache_init(mp, opt_dircache, mp->mnt_data);
+ pefs_opt_set(mp, opt_dircache, mp->mnt_data,
+ PM_DIRCACHE, "dircache");
+ error = 0;
+ }
+ if (opt_asyncreclaim >= 0) {
+ pefs_opt_set(mp, opt_dircache, mp->mnt_data,
+ PM_ASYNCRECLAIM, "asyncreclaim");
error = 0;
}
return (error);
@@ -233,7 +260,8 @@ pefs_mount(struct mount *mp)
pm->pm_lowervfs = lowerrootvp->v_mount;
if (lowerrootvp == mp->mnt_vnodecovered)
pm->pm_flags |= PM_ROOT_CANRECURSE;
- dircache_init(mp, opt_dircache, pm);
+ pefs_opt_set(mp, opt_dircache, pm, PM_DIRCACHE, "dircache");
+ pefs_opt_set(mp, opt_asyncreclaim, pm, PM_ASYNCRECLAIM, "asyncreclaim");
/*
* Save reference. Each mount also holds
Please sign in to comment.
Something went wrong with that request. Please try again.