aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifsd/vfs_cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifsd/vfs_cache.c')
-rw-r--r--fs/cifsd/vfs_cache.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/fs/cifsd/vfs_cache.c b/fs/cifsd/vfs_cache.c
index 6ea09fe82814..dcac1f0a29e4 100644
--- a/fs/cifsd/vfs_cache.c
+++ b/fs/cifsd/vfs_cache.c
@@ -10,7 +10,6 @@
#include "glob.h"
#include "vfs_cache.h"
-#include "buffer_pool.h"
#include "oplock.h"
#include "vfs.h"
#include "connection.h"
@@ -29,6 +28,7 @@ static DEFINE_RWLOCK(inode_hash_lock);
static struct ksmbd_file_table global_ft;
static atomic_long_t fd_limit;
+static struct kmem_cache *filp_cache;
void ksmbd_set_fd_limit(unsigned long limit)
{
@@ -315,7 +315,7 @@ static void __ksmbd_close_fd(struct ksmbd_file_table *ft, struct ksmbd_file *fp)
kfree(fp->filename);
if (ksmbd_stream_fd(fp))
kfree(fp->stream.name);
- ksmbd_free_file_struct(fp);
+ kmem_cache_free(filp_cache, fp);
}
static struct ksmbd_file *ksmbd_fp_get(struct ksmbd_file *fp)
@@ -539,10 +539,10 @@ unsigned int ksmbd_open_durable_fd(struct ksmbd_file *fp)
struct ksmbd_file *ksmbd_open_fd(struct ksmbd_work *work, struct file *filp)
{
- struct ksmbd_file *fp;
+ struct ksmbd_file *fp;
int ret;
- fp = ksmbd_alloc_file_struct();
+ fp = kmem_cache_zalloc(filp_cache, GFP_KERNEL);
if (!fp) {
ksmbd_err("Failed to allocate memory\n");
return ERR_PTR(-ENOMEM);
@@ -561,14 +561,14 @@ struct ksmbd_file *ksmbd_open_fd(struct ksmbd_work *work, struct file *filp)
fp->f_ci = ksmbd_inode_get(fp);
if (!fp->f_ci) {
- ksmbd_free_file_struct(fp);
+ kmem_cache_free(filp_cache, fp);
return ERR_PTR(-ENOMEM);
}
ret = __open_id(&work->sess->file_table, fp, OPEN_ID_TYPE_VOLATILE_ID);
if (ret) {
ksmbd_inode_put(fp->f_ci);
- ksmbd_free_file_struct(fp);
+ kmem_cache_free(filp_cache, fp);
return ERR_PTR(ret);
}
@@ -640,7 +640,7 @@ void ksmbd_free_global_file_table(void)
idr_for_each_entry(global_ft.idr, fp, id) {
__ksmbd_remove_durable_fd(fp);
- ksmbd_free_file_struct(fp);
+ kmem_cache_free(filp_cache, fp);
}
ksmbd_destroy_file_table(&global_ft);
@@ -683,3 +683,23 @@ void ksmbd_destroy_file_table(struct ksmbd_file_table *ft)
kfree(ft->idr);
ft->idr = NULL;
}
+
+int ksmbd_init_file_cache(void)
+{
+ filp_cache = kmem_cache_create("ksmbd_file_cache",
+ sizeof(struct ksmbd_file), 0,
+ SLAB_HWCACHE_ALIGN, NULL);
+ if (!filp_cache)
+ goto out;
+
+ return 0;
+
+out:
+ ksmbd_err("failed to allocate file cache\n");
+ return -ENOMEM;
+}
+
+void ksmbd_exit_file_cache(void)
+{
+ kmem_cache_destroy(filp_cache);
+}