Lines Matching refs:file

28  * Global file hash table
46 static inline void nlm_debug_print_file(char *msg, struct nlm_file *file)
48 struct inode *inode = locks_inode(file->f_file);
59 static inline void nlm_debug_print_file(char *msg, struct nlm_file *file)
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.
87 struct nlm_file *file;
95 /* Lock file table */
98 hlist_for_each_entry(file, &nlm_files[hash], f_list)
99 if (!nfs_compare_fh(&file->f_handle, f))
102 nlm_debug_print_fh("creating file for", f);
105 file = kzalloc(sizeof(*file), GFP_KERNEL);
106 if (!file)
109 memcpy(&file->f_handle, f, sizeof(struct nfs_fh));
110 mutex_init(&file->f_mutex);
111 INIT_HLIST_NODE(&file->f_list);
112 INIT_LIST_HEAD(&file->f_blocks);
114 /* Open the file. Note that this must not sleep for too long, else
118 * the file.
120 if ((nfserr = nlmsvc_ops->fopen(rqstp, f, &file->f_file)) != 0) {
125 hlist_add_head(&file->f_list, &nlm_files[hash]);
128 dprintk("lockd: found file %p (count %d)\n", file, file->f_count);
129 *result = file;
130 file->f_count++;
138 kfree(file);
143 * Delete a file after having released all locks, blocks and shares
146 nlm_delete_file(struct nlm_file *file)
148 nlm_debug_print_file("closing file", file);
149 if (!hlist_unhashed(&file->f_list)) {
150 hlist_del(&file->f_list);
151 nlmsvc_ops->fclose(file->f_file);
152 kfree(file);
154 printk(KERN_WARNING "lockd: attempt to release unknown file!\n");
159 * Loop over all locks on the given file and perform the specified
163 nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
166 struct inode *inode = nlmsvc_file_inode(file);
174 file->f_locks = 0;
181 file->f_locks++;
191 if (vfs_lock_file(file->f_file, F_SETLK, &lock, NULL) < 0) {
211 * Inspect a single file
214 nlm_inspect_file(struct nlm_host *host, struct nlm_file *file, nlm_host_match_fn_t match)
216 nlmsvc_traverse_blocks(host, file, match);
217 nlmsvc_traverse_shares(host, file, match);
218 return nlm_traverse_locks(host, file, match);
223 * shares on a given file.
226 nlm_file_inuse(struct nlm_file *file)
228 struct inode *inode = nlmsvc_file_inode(file);
232 if (file->f_count || !list_empty(&file->f_blocks) || file->f_shares)
245 file->f_locks = 0;
250 * Loop over all files in the file table.
254 int (*is_failover_file)(void *data, struct nlm_file *file))
257 struct nlm_file *file;
262 hlist_for_each_entry_safe(file, next, &nlm_files[i], f_list) {
263 if (is_failover_file && !is_failover_file(data, file))
265 file->f_count++;
268 /* Traverse locks, blocks and shares of this file
269 * and update file->f_locks count */
270 if (nlm_inspect_file(data, file, match))
274 file->f_count--;
275 /* No more references to this file. Let go of it. */
276 if (list_empty(&file->f_blocks) && !file->f_locks
277 && !file->f_shares && !file->f_count) {
278 hlist_del(&file->f_list);
279 nlmsvc_ops->fclose(file->f_file);
280 kfree(file);
289 * Release file. If there are no more remote locks on this file,
298 nlm_release_file(struct nlm_file *file)
301 file, file->f_count);
303 /* Lock file table */
306 /* If there are no more locks etc, delete the file */
307 if (--file->f_count == 0 && !nlm_file_inuse(file))
308 nlm_delete_file(file);
414 nlmsvc_match_sb(void *datap, struct nlm_file *file)
418 return sb == locks_inode(file->f_file)->i_sb;
422 * nlmsvc_unlock_all_by_sb - release locks held on this file system
425 * Release all locks held by clients accessing this file system.