diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 13ea532..9701827 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -42,6 +42,7 @@
 #include "cifsproto.h"
 #include "cifs_debug.h"
 #include "cifs_fs_sb.h"
+#include "cifs_lock_storage.h"
 #include <linux/mm.h>
 #include <linux/key-type.h>
 #include "dns_resolve.h"
@@ -1102,6 +1103,7 @@ init_cifs(void)
        rwlock_init(&GlobalSMBSeslock);
        rwlock_init(&cifs_tcp_ses_lock);
        spin_lock_init(&GlobalMid_Lock);
+       cifs_lock_storage_init();

        if (cifs_max_pending < 2) {
                cifs_max_pending = 2;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 81747ac..2d2e3f1 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -38,6 +38,7 @@
 #include "cifs_unicode.h"
 #include "cifs_debug.h"
 #include "cifs_fs_sb.h"
+#include "cifs_lock_storage.h"

 static inline struct cifsFileInfo *cifs_init_private(
        struct cifsFileInfo *private_data, struct inode *inode,
@@ -640,7 +641,6 @@ int cifs_close(struct inode *inode, struct file *file)
        cifs_sb = CIFS_SB(inode->i_sb);
        pTcon = cifs_sb->tcon;
        if (pSMBFile) {
-               struct cifsLockInfo *li, *tmp;
                write_lock(&GlobalSMBSeslock);
                pSMBFile->closePend = true;
                if (pTcon) {
@@ -674,15 +674,6 @@ int cifs_close(struct inode *inode, struct file *file)
                } else
                        write_unlock(&GlobalSMBSeslock);

-               /* Delete any outstanding lock records.
-                  We'll lose them when the file is closed anyway. */
-               mutex_lock(&pSMBFile->lock_mutex);
-               list_for_each_entry_safe(li, tmp, &pSMBFile->llist, llist) {
-                       list_del(&li->llist);
-                       kfree(li);
-               }
-               mutex_unlock(&pSMBFile->lock_mutex);
-
                write_lock(&GlobalSMBSeslock);
                list_del(&pSMBFile->flist);
                list_del(&pSMBFile->tlist);
@@ -773,22 +764,6 @@ int cifs_closedir(struct inode *inode, struct file *file)
        return rc;
 }

-static int store_file_lock(struct cifsFileInfo *fid, __u64 len,
-                               __u64 offset, __u8 lockType)
-{
-       struct cifsLockInfo *li =
-               kmalloc(sizeof(struct cifsLockInfo), GFP_KERNEL);
-       if (li == NULL)
-               return -ENOMEM;
-       li->offset = offset;
-       li->length = len;
-       li->type = lockType;
-       mutex_lock(&fid->lock_mutex);
-       list_add(&li->llist, &fid->llist);
-       mutex_unlock(&fid->lock_mutex);
-       return 0;
-}
-
 int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
 {
        int rc, xid;
@@ -935,33 +910,14 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)

                        if (rc == 0) {
                                /* For Windows locks we must store them. */
-                               rc = store_file_lock(fid, length,
-                                               pfLock->fl_start, lockType);
+                               rc = cifs_lock_storage_add_lock(fid->pid, fid->pInode->i_ino,
+                                               fid->netfid, pfLock->fl_start, length, lockType);
                        }
                } else if (numUnlock) {
                        /* For each stored lock that this unlock overlaps
                           completely, unlock it. */
-                       int stored_rc = 0;
-                       struct cifsLockInfo *li, *tmp;
-
-                       rc = 0;
-                       mutex_lock(&fid->lock_mutex);
-                       list_for_each_entry_safe(li, tmp, &fid->llist, llist) {
-                               if (pfLock->fl_start <= li->offset &&
-                                               (pfLock->fl_start + length) >=
-                                               (li->offset + li->length)) {
-                                       stored_rc = CIFSSMBLock(xid, tcon,
-                                                       netfid,
-                                                       li->length, li->offset,
-                                                       1, 0, li->type, false);
-                                       if (stored_rc)
-                                               rc = stored_rc;
-
-                                       list_del(&li->llist);
-                                       kfree(li);
-                               }
-                       }
-                       mutex_unlock(&fid->lock_mutex);
+                       rc = cifs_lock_storage_del_lock(xid, pTcon, fid->pid, fid->pInode->i_ino,
+                                               pfLock->fl_start, length, lockType);
                }
        }

