* Load it up with "size" bytes of data from "buf".
  * Set the mtime & ctime to the date that this record was originally stored.
  */
-int pstore_mkfile(struct pstore_record *record)
+int pstore_mkfile(struct dentry *root, struct pstore_record *record)
 {
-       struct dentry           *root = pstore_sb->s_root;
        struct dentry           *dentry;
        struct inode            *inode;
        int                     rc = 0;
        unsigned long           flags;
        size_t                  size = record->size + record->ecc_notice_size;
 
+       WARN_ON(!inode_is_locked(d_inode(root)));
+
        spin_lock_irqsave(&allpstore_lock, flags);
        list_for_each_entry(pos, &allpstore, list) {
                if (pos->record->type == record->type &&
                return rc;
 
        rc = -ENOMEM;
-       inode = pstore_get_inode(pstore_sb);
+       inode = pstore_get_inode(root->d_sb);
        if (!inode)
                goto fail;
        inode->i_mode = S_IFREG | 0444;
                break;
        }
 
-       inode_lock(d_inode(root));
-
        dentry = d_alloc_name(root, name);
        if (!dentry)
-               goto fail_lockedalloc;
+               goto fail_private;
 
        inode->i_size = private->total_size = size;
 
        list_add(&private->list, &allpstore);
        spin_unlock_irqrestore(&allpstore_lock, flags);
 
-       inode_unlock(d_inode(root));
-
        return 0;
 
-fail_lockedalloc:
-       inode_unlock(d_inode(root));
+fail_private:
        free_pstore_private(private);
 fail_alloc:
        iput(inode);
        return rc;
 }
 
+/*
+ * Read all the records from the persistent store. Create
+ * files in our filesystem.  Don't warn about -EEXIST errors
+ * when we are re-scanning the backing store looking to add new
+ * error records.
+ */
+void pstore_get_records(int quiet)
+{
+       struct pstore_info *psi = psinfo;
+       struct dentry *root;
+
+       if (!psi || !pstore_sb)
+               return;
+
+       root = pstore_sb->s_root;
+
+       inode_lock(d_inode(root));
+       pstore_get_backend_records(psi, root, quiet);
+       inode_unlock(d_inode(root));
+}
+
 static int pstore_fill_super(struct super_block *sb, void *data, int silent)
 {
        struct inode *inode;
 
 
 extern void    pstore_set_kmsg_bytes(int);
 extern void    pstore_get_records(int);
-extern int     pstore_mkfile(struct pstore_record *record);
+extern void    pstore_get_backend_records(struct pstore_info *psi,
+                                          struct dentry *root, int quiet);
+extern int     pstore_mkfile(struct dentry *root,
+                             struct pstore_record *record);
 extern bool    pstore_is_mounted(void);
 
 #endif
 
 }
 
 /*
- * Read all the records from the persistent store. Create
+ * Read all the records from one persistent store backend. Create
  * files in our filesystem.  Don't warn about -EEXIST errors
  * when we are re-scanning the backing store looking to add new
  * error records.
  */
-void pstore_get_records(int quiet)
+void pstore_get_backend_records(struct pstore_info *psi,
+                               struct dentry *root, int quiet)
 {
-       struct pstore_info *psi = psinfo;
        int failed = 0;
 
-       if (!psi)
+       if (!psi || !root)
                return;
 
        mutex_lock(&psi->read_mutex);
                        break;
 
                decompress_record(record);
-               rc = pstore_mkfile(record);
+               rc = pstore_mkfile(root, record);
                if (rc) {
                        /* pstore_mkfile() did not take record, so free it. */
                        kfree(record->buf);