--- /dev/null
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) Samsung Electronics, 2018
+ *
+ * 2018 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+
+#include <linux/dcache.h>
+#include <linux/namei.h>
+#include "swap_dcache.h"
+
+
+static atomic_t g_counter = ATOMIC_INIT(0);
+
+
+struct dentry *swap_dget_by_path(const char *filepath)
+{
+ struct path path;
+ struct dentry *dentry = NULL;
+
+ if (kern_path(filepath, LOOKUP_FOLLOW, &path) == 0) {
+ dentry = swap_dget(path.dentry);
+ path_put(&path);
+ }
+
+ return dentry;
+}
+EXPORT_SYMBOL_GPL(swap_dget_by_path);
+
+struct dentry *swap_dget(struct dentry *dentry)
+{
+ if (dentry) {
+ atomic_inc(&g_counter);
+ dget(dentry);
+ }
+
+ return dentry;
+}
+EXPORT_SYMBOL_GPL(swap_dget);
+
+void swap_dput(struct dentry *dentry)
+{
+ if (dentry) {
+ dput(dentry);
+ atomic_dec(&g_counter);
+ }
+}
+EXPORT_SYMBOL_GPL(swap_dput);
+
+int swap_dentry_init(void)
+{
+ return 0;
+}
+
+void swap_dentry_uninit(void)
+{
+ int counter = atomic_read(&g_counter);
+
+ WARN(counter, "Incorrect dentry usage, counter=%d", counter);
+ BUG_ON(counter < 0);
+}
--- /dev/null
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) Samsung Electronics, 2018
+ *
+ * 2018 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+#ifndef _SWAP_DCACHE_H
+#define _SWAP_DCACHE_H
+
+
+struct dentry;
+
+
+struct dentry *swap_dget_by_path(const char *filepath);
+struct dentry *swap_dget(struct dentry *dentry);
+void swap_dput(struct dentry *dentry);
+
+int swap_dentry_init(void);
+void swap_dentry_uninit(void);
+
+
+#endif /* _SWAP_DCACHE_H */