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 = nlmsvc_file_inode(file); 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
80 * Open the file. Note that if we're reexporting, for example,
84 * the file.
87 struct nlm_file *file, int mode) in nlm_do_fopen() argument
89 struct file **fp = &file->f_file[mode]; in nlm_do_fopen()
94 nfserr = nlmsvc_ops->fopen(rqstp, &file->f_handle, fp, mode); in nlm_do_fopen()
101 * Lookup file info. If it doesn't exist, create a file info struct
102 * and open a (VFS) file for the given inode.
108 struct nlm_file *file; in nlm_lookup_file() local
118 /* Lock file table */ in nlm_lookup_file()
121 hlist_for_each_entry(file, &nlm_files[hash], f_list) in nlm_lookup_file()
122 if (!nfs_compare_fh(&file->f_handle, &lock->fh)) { in nlm_lookup_file()
123 mutex_lock(&file->f_mutex); in nlm_lookup_file()
124 nfserr = nlm_do_fopen(rqstp, file, mode); in nlm_lookup_file()
125 mutex_unlock(&file->f_mutex); in nlm_lookup_file()
128 nlm_debug_print_fh("creating file for", &lock->fh); in nlm_lookup_file()
131 file = kzalloc(sizeof(*file), GFP_KERNEL); in nlm_lookup_file()
132 if (!file) in nlm_lookup_file()
135 memcpy(&file->f_handle, &lock->fh, sizeof(struct nfs_fh)); in nlm_lookup_file()
136 mutex_init(&file->f_mutex); in nlm_lookup_file()
137 INIT_HLIST_NODE(&file->f_list); in nlm_lookup_file()
138 INIT_LIST_HEAD(&file->f_blocks); in nlm_lookup_file()
140 nfserr = nlm_do_fopen(rqstp, file, mode); in nlm_lookup_file()
144 hlist_add_head(&file->f_list, &nlm_files[hash]); in nlm_lookup_file()
147 dprintk("lockd: found file %p (count %d)\n", file, file->f_count); in nlm_lookup_file()
148 *result = file; in nlm_lookup_file()
149 file->f_count++; in nlm_lookup_file()
156 kfree(file); in nlm_lookup_file()
161 * Delete a file after having released all locks, blocks and shares
164 nlm_delete_file(struct nlm_file *file) in nlm_delete_file() argument
166 nlm_debug_print_file("closing file", file); in nlm_delete_file()
167 if (!hlist_unhashed(&file->f_list)) { in nlm_delete_file()
168 hlist_del(&file->f_list); in nlm_delete_file()
169 if (file->f_file[O_RDONLY]) in nlm_delete_file()
170 nlmsvc_ops->fclose(file->f_file[O_RDONLY]); in nlm_delete_file()
171 if (file->f_file[O_WRONLY]) in nlm_delete_file()
172 nlmsvc_ops->fclose(file->f_file[O_WRONLY]); in nlm_delete_file()
173 kfree(file); in nlm_delete_file()
175 printk(KERN_WARNING "lockd: attempt to release unknown file!\n"); in nlm_delete_file()
179 static int nlm_unlock_files(struct nlm_file *file, fl_owner_t owner) in nlm_unlock_files() argument
188 if (file->f_file[O_RDONLY] && in nlm_unlock_files()
189 vfs_lock_file(file->f_file[O_RDONLY], F_SETLK, &lock, NULL)) in nlm_unlock_files()
191 if (file->f_file[O_WRONLY] && in nlm_unlock_files()
192 vfs_lock_file(file->f_file[O_WRONLY], F_SETLK, &lock, NULL)) in nlm_unlock_files()
201 * Loop over all locks on the given file and perform the specified
205 nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file, in nlm_traverse_locks() argument
208 struct inode *inode = nlmsvc_file_inode(file); in nlm_traverse_locks()
216 file->f_locks = 0; in nlm_traverse_locks()
223 file->f_locks++; in nlm_traverse_locks()
229 if (nlm_unlock_files(file, fl->fl_owner)) in nlm_traverse_locks()
246 * Inspect a single file
249 nlm_inspect_file(struct nlm_host *host, struct nlm_file *file, nlm_host_match_fn_t match) in nlm_inspect_file() argument
251 nlmsvc_traverse_blocks(host, file, match); in nlm_inspect_file()
252 nlmsvc_traverse_shares(host, file, match); in nlm_inspect_file()
253 return nlm_traverse_locks(host, file, match); in nlm_inspect_file()
258 * shares on a given file.
261 nlm_file_inuse(struct nlm_file *file) in nlm_file_inuse() argument
263 struct inode *inode = nlmsvc_file_inode(file); in nlm_file_inuse()
267 if (file->f_count || !list_empty(&file->f_blocks) || file->f_shares) in nlm_file_inuse()
280 file->f_locks = 0; in nlm_file_inuse()
284 static void nlm_close_files(struct nlm_file *file) in nlm_close_files() argument
286 if (file->f_file[O_RDONLY]) in nlm_close_files()
287 nlmsvc_ops->fclose(file->f_file[O_RDONLY]); in nlm_close_files()
288 if (file->f_file[O_WRONLY]) in nlm_close_files()
289 nlmsvc_ops->fclose(file->f_file[O_WRONLY]); in nlm_close_files()
293 * Loop over all files in the file table.
297 int (*is_failover_file)(void *data, struct nlm_file *file)) in nlm_traverse_files() argument
300 struct nlm_file *file; in nlm_traverse_files() local
305 hlist_for_each_entry_safe(file, next, &nlm_files[i], f_list) { in nlm_traverse_files()
306 if (is_failover_file && !is_failover_file(data, file)) in nlm_traverse_files()
308 file->f_count++; in nlm_traverse_files()
311 /* Traverse locks, blocks and shares of this file in nlm_traverse_files()
312 * and update file->f_locks count */ in nlm_traverse_files()
313 if (nlm_inspect_file(data, file, match)) in nlm_traverse_files()
317 file->f_count--; in nlm_traverse_files()
318 /* No more references to this file. Let go of it. */ in nlm_traverse_files()
319 if (list_empty(&file->f_blocks) && !file->f_locks in nlm_traverse_files()
320 && !file->f_shares && !file->f_count) { in nlm_traverse_files()
321 hlist_del(&file->f_list); in nlm_traverse_files()
322 nlm_close_files(file); in nlm_traverse_files()
323 kfree(file); in nlm_traverse_files()
332 * Release file. If there are no more remote locks on this file,
341 nlm_release_file(struct nlm_file *file) in nlm_release_file() argument
344 file, file->f_count); in nlm_release_file()
346 /* Lock file table */ in nlm_release_file()
349 /* If there are no more locks etc, delete the file */ in nlm_release_file()
350 if (--file->f_count == 0 && !nlm_file_inuse(file)) in nlm_release_file()
351 nlm_delete_file(file); in nlm_release_file()
458 nlmsvc_match_sb(void *datap, struct nlm_file *file) in nlmsvc_match_sb() argument
462 return sb == nlmsvc_file_inode(file)->i_sb; in nlmsvc_match_sb()
466 * nlmsvc_unlock_all_by_sb - release locks held on this file system
469 * Release all locks held by clients accessing this file system.