Lines Matching full:file

28  * Global file hash table
46 static inline void nlm_debug_print_file(char *msg, struct nlm_file *file) in nlm_debug_print_file() argument
48 struct inode *inode = file->f_file->f_path.dentry->d_inode; in nlm_debug_print_file()
59 static inline void nlm_debug_print_file(char *msg, struct nlm_file *file) in nlm_debug_print_file() argument
75 * Lookup file info. If it doesn't exist, create a file info struct
76 * and open a (VFS) file for the given inode.
79 * Note that we open the file O_RDONLY even when creating write locks.
88 struct nlm_file *file; in nlm_lookup_file() local
96 /* Lock file table */ in nlm_lookup_file()
99 hlist_for_each_entry(file, pos, &nlm_files[hash], f_list) in nlm_lookup_file()
100 if (!nfs_compare_fh(&file->f_handle, f)) in nlm_lookup_file()
103 nlm_debug_print_fh("creating file for", f); in nlm_lookup_file()
106 file = kzalloc(sizeof(*file), GFP_KERNEL); in nlm_lookup_file()
107 if (!file) in nlm_lookup_file()
110 memcpy(&file->f_handle, f, sizeof(struct nfs_fh)); in nlm_lookup_file()
111 mutex_init(&file->f_mutex); in nlm_lookup_file()
112 INIT_HLIST_NODE(&file->f_list); in nlm_lookup_file()
113 INIT_LIST_HEAD(&file->f_blocks); in nlm_lookup_file()
115 /* Open the file. Note that this must not sleep for too long, else in nlm_lookup_file()
119 * the file. in nlm_lookup_file()
121 if ((nfserr = nlmsvc_ops->fopen(rqstp, f, &file->f_file)) != 0) { in nlm_lookup_file()
126 hlist_add_head(&file->f_list, &nlm_files[hash]); in nlm_lookup_file()
129 dprintk("lockd: found file %p (count %d)\n", file, file->f_count); in nlm_lookup_file()
130 *result = file; in nlm_lookup_file()
131 file->f_count++; in nlm_lookup_file()
139 kfree(file); in nlm_lookup_file()
144 * Delete a file after having released all locks, blocks and shares
147 nlm_delete_file(struct nlm_file *file) in nlm_delete_file() argument
149 nlm_debug_print_file("closing file", file); in nlm_delete_file()
150 if (!hlist_unhashed(&file->f_list)) { in nlm_delete_file()
151 hlist_del(&file->f_list); in nlm_delete_file()
152 nlmsvc_ops->fclose(file->f_file); in nlm_delete_file()
153 kfree(file); in nlm_delete_file()
155 printk(KERN_WARNING "lockd: attempt to release unknown file!\n"); in nlm_delete_file()
160 * Loop over all locks on the given file and perform the specified
164 nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file, in nlm_traverse_locks() argument
167 struct inode *inode = nlmsvc_file_inode(file); in nlm_traverse_locks()
172 file->f_locks = 0; in nlm_traverse_locks()
179 file->f_locks++; in nlm_traverse_locks()
189 if (vfs_lock_file(file->f_file, F_SETLK, &lock, NULL) < 0) { in nlm_traverse_locks()
209 * Inspect a single file
212 nlm_inspect_file(struct nlm_host *host, struct nlm_file *file, nlm_host_match_fn_t match) in nlm_inspect_file() argument
214 nlmsvc_traverse_blocks(host, file, match); in nlm_inspect_file()
215 nlmsvc_traverse_shares(host, file, match); in nlm_inspect_file()
216 return nlm_traverse_locks(host, file, match); in nlm_inspect_file()
221 * shares on a given file.
224 nlm_file_inuse(struct nlm_file *file) in nlm_file_inuse() argument
226 struct inode *inode = nlmsvc_file_inode(file); in nlm_file_inuse()
229 if (file->f_count || !list_empty(&file->f_blocks) || file->f_shares) in nlm_file_inuse()
240 file->f_locks = 0; in nlm_file_inuse()
245 * Loop over all files in the file table.
249 int (*is_failover_file)(void *data, struct nlm_file *file)) in nlm_traverse_files() argument
252 struct nlm_file *file; in nlm_traverse_files() local
257 hlist_for_each_entry_safe(file, pos, next, &nlm_files[i], f_list) { in nlm_traverse_files()
258 if (is_failover_file && !is_failover_file(data, file)) in nlm_traverse_files()
260 file->f_count++; in nlm_traverse_files()
263 /* Traverse locks, blocks and shares of this file in nlm_traverse_files()
264 * and update file->f_locks count */ in nlm_traverse_files()
265 if (nlm_inspect_file(data, file, match)) in nlm_traverse_files()
269 file->f_count--; in nlm_traverse_files()
270 /* No more references to this file. Let go of it. */ in nlm_traverse_files()
271 if (list_empty(&file->f_blocks) && !file->f_locks in nlm_traverse_files()
272 && !file->f_shares && !file->f_count) { in nlm_traverse_files()
273 hlist_del(&file->f_list); in nlm_traverse_files()
274 nlmsvc_ops->fclose(file->f_file); in nlm_traverse_files()
275 kfree(file); in nlm_traverse_files()
284 * Release file. If there are no more remote locks on this file,
293 nlm_release_file(struct nlm_file *file) in nlm_release_file() argument
296 file, file->f_count); in nlm_release_file()
298 /* Lock file table */ in nlm_release_file()
301 /* If there are no more locks etc, delete the file */ in nlm_release_file()
302 if (--file->f_count == 0 && !nlm_file_inuse(file)) in nlm_release_file()
303 nlm_delete_file(file); in nlm_release_file()
402 nlmsvc_match_sb(void *datap, struct nlm_file *file) in nlmsvc_match_sb() argument
406 return sb == file->f_file->f_path.dentry->d_sb; in nlmsvc_match_sb()
410 * nlmsvc_unlock_all_by_sb - release locks held on this file system
413 * Release all locks held by clients accessing this file system.