Lines Matching +full:key +full:- +full:release
1 // SPDX-License-Identifier: GPL-2.0-or-later
37 .release = afs_release,
84 * Discard a pin on a writeback key.
88 if (wbk && refcount_dec_and_test(&wbk->usage)) { in afs_put_wb_key()
89 key_put(wbk->key); in afs_put_wb_key()
95 * Cache key for writeback.
103 return -ENOMEM; in afs_cache_wb_key()
104 refcount_set(&wbk->usage, 2); in afs_cache_wb_key()
105 wbk->key = af->key; in afs_cache_wb_key()
107 spin_lock(&vnode->wb_lock); in afs_cache_wb_key()
108 list_for_each_entry(p, &vnode->wb_keys, vnode_link) { in afs_cache_wb_key()
109 if (p->key == wbk->key) in afs_cache_wb_key()
113 key_get(wbk->key); in afs_cache_wb_key()
114 list_add_tail(&wbk->vnode_link, &vnode->wb_keys); in afs_cache_wb_key()
115 spin_unlock(&vnode->wb_lock); in afs_cache_wb_key()
116 af->wb = wbk; in afs_cache_wb_key()
120 refcount_inc(&p->usage); in afs_cache_wb_key()
121 spin_unlock(&vnode->wb_lock); in afs_cache_wb_key()
122 af->wb = p; in afs_cache_wb_key()
128 * open an AFS file or directory and attach a key to it
134 struct key *key; in afs_open() local
137 _enter("{%llx:%llu},", vnode->fid.vid, vnode->fid.vnode); in afs_open()
139 key = afs_request_key(vnode->volume->cell); in afs_open()
140 if (IS_ERR(key)) { in afs_open()
141 ret = PTR_ERR(key); in afs_open()
147 ret = -ENOMEM; in afs_open()
150 af->key = key; in afs_open()
152 ret = afs_validate(vnode, key); in afs_open()
156 if (file->f_mode & FMODE_WRITE) { in afs_open()
162 if (file->f_flags & O_TRUNC) in afs_open()
163 set_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags); in afs_open()
165 fscache_use_cookie(afs_vnode_cache(vnode), file->f_mode & FMODE_WRITE); in afs_open()
167 file->private_data = af; in afs_open()
174 key_put(key); in afs_open()
181 * release an AFS file or directory and discard its key
187 struct afs_file *af = file->private_data; in afs_release()
191 _enter("{%llx:%llu},", vnode->fid.vid, vnode->fid.vnode); in afs_release()
193 if ((file->f_mode & FMODE_WRITE)) in afs_release()
196 file->private_data = NULL; in afs_release()
197 if (af->wb) in afs_release()
198 afs_put_wb_key(af->wb); in afs_release()
200 if ((file->f_mode & FMODE_WRITE)) { in afs_release()
201 i_size = i_size_read(&vnode->netfs.inode); in afs_release()
208 key_put(af->key); in afs_release()
224 refcount_set(&req->usage, 1); in afs_alloc_read()
234 if (refcount_dec_and_test(&req->usage)) { in afs_put_read()
235 if (req->cleanup) in afs_put_read()
236 req->cleanup(req); in afs_put_read()
237 key_put(req->key); in afs_put_read()
244 struct afs_read *req = op->fetch.req; in afs_fetch_data_notify()
245 struct netfs_io_subrequest *subreq = req->subreq; in afs_fetch_data_notify()
246 int error = op->error; in afs_fetch_data_notify()
248 if (error == -ECONNABORTED) in afs_fetch_data_notify()
249 error = afs_abort_to_error(op->ac.abort_code); in afs_fetch_data_notify()
250 req->error = error; in afs_fetch_data_notify()
253 __set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags); in afs_fetch_data_notify()
254 netfs_subreq_terminated(subreq, error ?: req->actual_len, false); in afs_fetch_data_notify()
255 req->subreq = NULL; in afs_fetch_data_notify()
256 } else if (req->done) { in afs_fetch_data_notify()
257 req->done(req); in afs_fetch_data_notify()
263 struct afs_vnode *vnode = op->file[0].vnode; in afs_fetch_data_success()
265 _enter("op=%08x", op->debug_id); in afs_fetch_data_success()
266 afs_vnode_commit_status(op, &op->file[0]); in afs_fetch_data_success()
268 atomic_long_add(op->fetch.req->actual_len, &op->net->n_fetch_bytes); in afs_fetch_data_success()
274 op->fetch.req->error = op->error; in afs_fetch_data_put()
275 afs_put_read(op->fetch.req); in afs_fetch_data_put()
295 vnode->volume->name, in afs_fetch_data()
296 vnode->fid.vid, in afs_fetch_data()
297 vnode->fid.vnode, in afs_fetch_data()
298 vnode->fid.unique, in afs_fetch_data()
299 key_serial(req->key)); in afs_fetch_data()
301 op = afs_alloc_operation(req->key, vnode->volume); in afs_fetch_data()
303 if (req->subreq) in afs_fetch_data()
304 netfs_subreq_terminated(req->subreq, PTR_ERR(op), false); in afs_fetch_data()
310 op->fetch.req = afs_get_read(req); in afs_fetch_data()
311 op->ops = &afs_fetch_data_operation; in afs_fetch_data()
317 struct afs_vnode *vnode = AFS_FS_I(subreq->rreq->inode); in afs_issue_read()
322 return netfs_subreq_terminated(subreq, -ENOMEM, false); in afs_issue_read()
324 fsreq->subreq = subreq; in afs_issue_read()
325 fsreq->pos = subreq->start + subreq->transferred; in afs_issue_read()
326 fsreq->len = subreq->len - subreq->transferred; in afs_issue_read()
327 fsreq->key = key_get(subreq->rreq->netfs_priv); in afs_issue_read()
328 fsreq->vnode = vnode; in afs_issue_read()
329 fsreq->iter = &fsreq->def_iter; in afs_issue_read()
331 iov_iter_xarray(&fsreq->def_iter, ITER_DEST, in afs_issue_read()
332 &fsreq->vnode->netfs.inode.i_mapping->i_pages, in afs_issue_read()
333 fsreq->pos, fsreq->len); in afs_issue_read()
335 afs_fetch_data(fsreq->vnode, fsreq); in afs_issue_read()
341 struct afs_vnode *vnode = AFS_FS_I(folio->mapping->host); in afs_symlink_read_folio()
347 return -ENOMEM; in afs_symlink_read_folio()
349 fsreq->pos = folio_pos(folio); in afs_symlink_read_folio()
350 fsreq->len = folio_size(folio); in afs_symlink_read_folio()
351 fsreq->vnode = vnode; in afs_symlink_read_folio()
352 fsreq->iter = &fsreq->def_iter; in afs_symlink_read_folio()
353 iov_iter_xarray(&fsreq->def_iter, ITER_DEST, &folio->mapping->i_pages, in afs_symlink_read_folio()
354 fsreq->pos, fsreq->len); in afs_symlink_read_folio()
356 ret = afs_fetch_data(fsreq->vnode, fsreq); in afs_symlink_read_folio()
365 rreq->netfs_priv = key_get(afs_file_key(file)); in afs_init_request()
372 struct afs_vnode *vnode = AFS_FS_I(rreq->inode); in afs_begin_cache_operation()
374 return fscache_begin_read_operation(&rreq->cache_resources, in afs_begin_cache_operation()
377 return -ENOBUFS; in afs_begin_cache_operation()
386 return test_bit(AFS_VNODE_DELETED, &vnode->flags) ? -ESTALE : 0; in afs_check_write_begin()
391 key_put(rreq->netfs_priv); in afs_free_request()
440 return; /* Splits the dirty region - just absorb it */ in afs_invalidate_dirty()
467 * - release a page and clean up its private data if offset is 0 (indicating
473 _enter("{%lu},%zu,%zu", folio->index, offset, length); in afs_invalidate_folio()
485 * release a page and clean up its private state if it's not busy
486 * - return true if the page can now be released, false if not
493 vnode->fid.vid, vnode->fid.vnode, folio_index(folio), folio->flags, in afs_release_folio()
519 if (atomic_inc_return(&vnode->cb_nr_mmap) == 1) { in afs_add_open_mmap()
520 down_write(&vnode->volume->cell->fs_open_mmaps_lock); in afs_add_open_mmap()
522 if (list_empty(&vnode->cb_mmap_link)) in afs_add_open_mmap()
523 list_add_tail(&vnode->cb_mmap_link, in afs_add_open_mmap()
524 &vnode->volume->cell->fs_open_mmaps); in afs_add_open_mmap()
526 up_write(&vnode->volume->cell->fs_open_mmaps_lock); in afs_add_open_mmap()
532 if (!atomic_dec_and_test(&vnode->cb_nr_mmap)) in afs_drop_open_mmap()
535 down_write(&vnode->volume->cell->fs_open_mmaps_lock); in afs_drop_open_mmap()
537 if (atomic_read(&vnode->cb_nr_mmap) == 0) in afs_drop_open_mmap()
538 list_del_init(&vnode->cb_mmap_link); in afs_drop_open_mmap()
540 up_write(&vnode->volume->cell->fs_open_mmaps_lock); in afs_drop_open_mmap()
541 flush_work(&vnode->cb_work); in afs_drop_open_mmap()
556 vma->vm_ops = &afs_vm_ops; in afs_file_mmap()
564 afs_add_open_mmap(AFS_FS_I(file_inode(vma->vm_file))); in afs_vm_open()
569 afs_drop_open_mmap(AFS_FS_I(file_inode(vma->vm_file))); in afs_vm_close()
574 struct afs_vnode *vnode = AFS_FS_I(file_inode(vmf->vma->vm_file)); in afs_vm_map_pages()
583 struct afs_vnode *vnode = AFS_FS_I(file_inode(iocb->ki_filp)); in afs_file_read_iter()
584 struct afs_file *af = iocb->ki_filp->private_data; in afs_file_read_iter()
587 ret = afs_validate(vnode, af->key); in afs_file_read_iter()
599 struct afs_file *af = in->private_data; in afs_file_splice_read()
602 ret = afs_validate(vnode, af->key); in afs_file_splice_read()