Lines Matching refs:of
45 * pending queue is implemented as a singly linked list of kernfs_nodes.
95 struct kernfs_open_file *of = sf->private;
96 const struct kernfs_ops *ops = kernfs_ops(of->kn);
100 kernfs_put_active(of->kn);
105 struct kernfs_open_file *of = sf->private;
109 * @of->mutex nests outside active ref and is primarily to ensure that
112 mutex_lock(&of->mutex);
113 if (!kernfs_get_active(of->kn))
116 ops = kernfs_ops(of->kn);
134 struct kernfs_open_file *of = sf->private;
135 const struct kernfs_ops *ops = kernfs_ops(of->kn);
155 struct kernfs_open_file *of = sf->private;
159 mutex_unlock(&of->mutex);
164 struct kernfs_open_file *of = sf->private;
166 of->event = atomic_read(&of->kn->attr.open->event);
168 return of->kn->attr.ops->seq_show(sf, v);
186 struct kernfs_open_file *of = kernfs_of(iocb->ki_filp);
191 buf = of->prealloc_buf;
193 mutex_lock(&of->prealloc_mutex);
200 * @of->mutex nests outside active ref and is used both to ensure that
203 mutex_lock(&of->mutex);
204 if (!kernfs_get_active(of->kn)) {
206 mutex_unlock(&of->mutex);
210 of->event = atomic_read(&of->kn->attr.open->event);
211 ops = kernfs_ops(of->kn);
213 len = ops->read(of, buf, len, iocb->ki_pos);
217 kernfs_put_active(of->kn);
218 mutex_unlock(&of->mutex);
231 if (buf == of->prealloc_buf)
232 mutex_unlock(&of->prealloc_mutex);
257 struct kernfs_open_file *of = kernfs_of(iocb->ki_filp);
262 if (of->atomic_write_len) {
263 if (len > of->atomic_write_len)
269 buf = of->prealloc_buf;
271 mutex_lock(&of->prealloc_mutex);
284 * @of->mutex nests outside active ref and is used both to ensure that
287 mutex_lock(&of->mutex);
288 if (!kernfs_get_active(of->kn)) {
289 mutex_unlock(&of->mutex);
294 ops = kernfs_ops(of->kn);
296 len = ops->write(of, buf, len, iocb->ki_pos);
300 kernfs_put_active(of->kn);
301 mutex_unlock(&of->mutex);
307 if (buf == of->prealloc_buf)
308 mutex_unlock(&of->prealloc_mutex);
317 struct kernfs_open_file *of = kernfs_of(file);
319 if (!of->vm_ops)
322 if (!kernfs_get_active(of->kn))
325 if (of->vm_ops->open)
326 of->vm_ops->open(vma);
328 kernfs_put_active(of->kn);
334 struct kernfs_open_file *of = kernfs_of(file);
337 if (!of->vm_ops)
340 if (!kernfs_get_active(of->kn))
344 if (of->vm_ops->fault)
345 ret = of->vm_ops->fault(vmf);
347 kernfs_put_active(of->kn);
354 struct kernfs_open_file *of = kernfs_of(file);
357 if (!of->vm_ops)
360 if (!kernfs_get_active(of->kn))
364 if (of->vm_ops->page_mkwrite)
365 ret = of->vm_ops->page_mkwrite(vmf);
369 kernfs_put_active(of->kn);
377 struct kernfs_open_file *of = kernfs_of(file);
380 if (!of->vm_ops)
383 if (!kernfs_get_active(of->kn))
387 if (of->vm_ops->access)
388 ret = of->vm_ops->access(vma, addr, buf, len, write);
390 kernfs_put_active(of->kn);
399 struct kernfs_open_file *of = kernfs_of(file);
402 if (!of->vm_ops)
405 if (!kernfs_get_active(of->kn))
409 if (of->vm_ops->set_policy)
410 ret = of->vm_ops->set_policy(vma, new);
412 kernfs_put_active(of->kn);
420 struct kernfs_open_file *of = kernfs_of(file);
423 if (!of->vm_ops)
426 if (!kernfs_get_active(of->kn))
430 if (of->vm_ops->get_policy)
431 pol = of->vm_ops->get_policy(vma, addr);
433 kernfs_put_active(of->kn);
452 struct kernfs_open_file *of = kernfs_of(file);
457 * mmap path and of->mutex are prone to triggering spurious lockdep
460 * without grabbing @of->mutex by testing HAS_MMAP flag. See the
463 if (!(of->kn->flags & KERNFS_HAS_MMAP))
466 mutex_lock(&of->mutex);
469 if (!kernfs_get_active(of->kn))
472 ops = kernfs_ops(of->kn);
473 rc = ops->mmap(of, vma);
478 * PowerPC's pci_mmap of legacy_mem uses shmem_zero_setup()
479 * to satisfy versions of X which crash if the mmap fails: that
486 if (of->mmapped && of->vm_ops != vma->vm_ops)
498 of->mmapped = true;
499 of->vm_ops = vma->vm_ops;
502 kernfs_put_active(of->kn);
504 mutex_unlock(&of->mutex);
512 * @of: kernfs_open_file for this instance of open
515 * create one. @of is chained to the files list.
524 struct kernfs_open_file *of)
540 list_add_tail(&of->list, &on->files);
566 * @of: associated kernfs_open_file
568 * Put @kn->attr.open and unlink @of from the files list. If
575 struct kernfs_open_file *of)
583 if (of)
584 list_del(&of->list);
602 struct kernfs_open_file *of;
628 of = kzalloc(sizeof(struct kernfs_open_file), GFP_KERNEL);
629 if (!of)
634 * @of->mutex for files which implement mmap. This is a rather
636 * mm->mmap_lock - mmap nests @of->mutex under mm->mmap_lock and
638 * which mm->mmap_lock nests, while holding @of->mutex. As each
644 * Both paths of the branch look the same. They're supposed to
645 * look that way and give @of->mutex different static lockdep keys.
648 mutex_init(&of->mutex);
650 mutex_init(&of->mutex);
652 of->kn = kn;
653 of->file = file;
659 of->atomic_write_len = ops->atomic_write_len;
670 int len = of->atomic_write_len ?: PAGE_SIZE;
671 of->prealloc_buf = kmalloc(len + 1, GFP_KERNEL);
673 if (!of->prealloc_buf)
675 mutex_init(&of->prealloc_mutex);
690 of->seq_file = file->private_data;
691 of->seq_file->private = of;
698 error = kernfs_get_open_node(kn, of);
703 /* nobody has access to @of yet, skip @of->mutex */
704 error = ops->open(of);
714 kernfs_put_open_node(kn, of);
718 kfree(of->prealloc_buf);
719 kfree(of);
727 struct kernfs_open_file *of)
730 * @of is guaranteed to have no other file operations in flight and
732 * @kernfs_open_file_mutex is enough. @of->mutex can't be used
738 if (!of->released) {
744 kn->attr.ops->release(of);
745 of->released = true;
752 struct kernfs_open_file *of = kernfs_of(filp);
756 kernfs_release_file(kn, of);
760 kernfs_put_open_node(kn, of);
762 kfree(of->prealloc_buf);
763 kfree(of);
771 struct kernfs_open_file *of;
786 list_for_each_entry(of, &on->files, list) {
787 struct inode *inode = file_inode(of->file);
793 kernfs_release_file(kn, of);
815 __poll_t kernfs_generic_poll(struct kernfs_open_file *of, poll_table *wait)
817 struct kernfs_node *kn = kernfs_dentry_node(of->file->f_path.dentry);
820 poll_wait(of->file, &on->poll, wait);
822 if (of->event != atomic_read(&on->event))
830 struct kernfs_open_file *of = kernfs_of(filp);
838 ret = kn->attr.ops->poll(of, wait);
840 ret = kernfs_generic_poll(of, wait);
959 * @name: name of the file
960 * @mode: mode of the file
961 * @uid: uid of the file
962 * @gid: gid of the file
963 * @size: size of the file
966 * @ns: optional namespace tag of the file