cifs: Move some extern decls from .c files to .h
[linux-2.6-microblaze.git] / fs / smb / client / misc.c
index c2137ea..c3771fc 100644 (file)
@@ -27,9 +27,6 @@
 #include "fs_context.h"
 #include "cached_dir.h"
 
-extern mempool_t *cifs_sm_req_poolp;
-extern mempool_t *cifs_req_poolp;
-
 /* The xid serves as a useful identifier for each incoming vfs request,
    in a similar way to the mid which is useful to track each sent smb,
    and CurrentXid can also provide a running counter (although it
@@ -140,6 +137,7 @@ tcon_info_alloc(bool dir_leases_enabled)
        spin_lock_init(&ret_buf->stat_lock);
        atomic_set(&ret_buf->num_local_opens, 0);
        atomic_set(&ret_buf->num_remote_opens, 0);
+       ret_buf->stats_from_time = ktime_get_real_seconds();
 #ifdef CONFIG_CIFS_DFS_UPCALL
        INIT_LIST_HEAD(&ret_buf->dfs_ses_list);
 #endif
@@ -852,6 +850,40 @@ cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon, const char *path)
        free_dentry_path(page);
 }
 
+/*
+ * If a dentry has been deleted, all corresponding open handles should know that
+ * so that we do not defer close them.
+ */
+void cifs_mark_open_handles_for_deleted_file(struct inode *inode,
+                                            const char *path)
+{
+       struct cifsFileInfo *cfile;
+       void *page;
+       const char *full_path;
+       struct cifsInodeInfo *cinode = CIFS_I(inode);
+
+       page = alloc_dentry_path();
+       spin_lock(&cinode->open_file_lock);
+
+       /*
+        * note: we need to construct path from dentry and compare only if the
+        * inode has any hardlinks. When number of hardlinks is 1, we can just
+        * mark all open handles since they are going to be from the same file.
+        */
+       if (inode->i_nlink > 1) {
+               list_for_each_entry(cfile, &cinode->openFileList, flist) {
+                       full_path = build_path_from_dentry(cfile->dentry, page);
+                       if (!IS_ERR(full_path) && strcmp(full_path, path) == 0)
+                               cfile->status_file_deleted = true;
+               }
+       } else {
+               list_for_each_entry(cfile, &cinode->openFileList, flist)
+                       cfile->status_file_deleted = true;
+       }
+       spin_unlock(&cinode->open_file_lock);
+       free_dentry_path(page);
+}
+
 /* parses DFS referral V3 structure
  * caller is responsible for freeing target_nodes
  * returns: