Lines Matching +full:tcon +full:- +full:channel
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <linux/backing-dev.h>
83 current->comm, current->tgid); in cifs_posix_convert_flags()
124 struct cifs_tcon *tcon; in cifs_posix_open() local
130 return -ENOMEM; in cifs_posix_open()
138 tcon = tlink_tcon(tlink); in cifs_posix_open()
142 rc = CIFSPOSIXCreate(xid, tcon, posix_flags, mode, pnetfid, presp_data, in cifs_posix_open()
143 poplock, full_path, cifs_sb->local_nls, in cifs_posix_open()
150 if (presp_data->Type == cpu_to_le32(-1)) in cifs_posix_open()
163 rc = -ENOMEM; in cifs_posix_open()
178 struct cifs_tcon *tcon, unsigned int f_flags, __u32 *oplock, in cifs_nt_open() argument
186 struct TCP_Server_Info *server = tcon->ses->server; in cifs_nt_open()
189 if (!server->ops->open) in cifs_nt_open()
190 return -ENOSYS; in cifs_nt_open()
198 * ---------- ---------------- in cifs_nt_open()
224 return -ENOMEM; in cifs_nt_open()
233 oparms.tcon = tcon; in cifs_nt_open()
242 rc = server->ops->open(xid, &oparms, oplock, buf); in cifs_nt_open()
248 if (tcon->unix_ext) in cifs_nt_open()
249 rc = cifs_get_inode_info_unix(&inode, full_path, inode->i_sb, in cifs_nt_open()
252 rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb, in cifs_nt_open()
256 server->ops->close(xid, tcon, fid); in cifs_nt_open()
257 if (rc == -ESTALE) in cifs_nt_open()
258 rc = -EOPENSTALE; in cifs_nt_open()
272 down_read(&cinode->lock_sem); in cifs_has_mand_locks()
273 list_for_each_entry(cur, &cinode->llist, llist) { in cifs_has_mand_locks()
274 if (!list_empty(&cur->locks)) { in cifs_has_mand_locks()
279 up_read(&cinode->lock_sem); in cifs_has_mand_locks()
301 struct cifs_tcon *tcon = tlink_tcon(tlink); in cifs_new_fileinfo() local
302 struct TCP_Server_Info *server = tcon->ses->server; in cifs_new_fileinfo()
314 INIT_LIST_HEAD(&fdlocks->locks); in cifs_new_fileinfo()
315 fdlocks->cfile = cfile; in cifs_new_fileinfo()
316 cfile->llist = fdlocks; in cifs_new_fileinfo()
318 cfile->count = 1; in cifs_new_fileinfo()
319 cfile->pid = current->tgid; in cifs_new_fileinfo()
320 cfile->uid = current_fsuid(); in cifs_new_fileinfo()
321 cfile->dentry = dget(dentry); in cifs_new_fileinfo()
322 cfile->f_flags = file->f_flags; in cifs_new_fileinfo()
323 cfile->invalidHandle = false; in cifs_new_fileinfo()
324 cfile->tlink = cifs_get_tlink(tlink); in cifs_new_fileinfo()
325 INIT_WORK(&cfile->oplock_break, cifs_oplock_break); in cifs_new_fileinfo()
326 INIT_WORK(&cfile->put, cifsFileInfo_put_work); in cifs_new_fileinfo()
327 mutex_init(&cfile->fh_mutex); in cifs_new_fileinfo()
328 spin_lock_init(&cfile->file_info_lock); in cifs_new_fileinfo()
330 cifs_sb_active(inode->i_sb); in cifs_new_fileinfo()
336 if (server->ops->is_read_op(oplock) && cifs_has_mand_locks(cinode)) { in cifs_new_fileinfo()
341 cifs_down_write(&cinode->lock_sem); in cifs_new_fileinfo()
342 list_add(&fdlocks->llist, &cinode->llist); in cifs_new_fileinfo()
343 up_write(&cinode->lock_sem); in cifs_new_fileinfo()
345 spin_lock(&tcon->open_file_lock); in cifs_new_fileinfo()
346 if (fid->pending_open->oplock != CIFS_OPLOCK_NO_CHANGE && oplock) in cifs_new_fileinfo()
347 oplock = fid->pending_open->oplock; in cifs_new_fileinfo()
348 list_del(&fid->pending_open->olist); in cifs_new_fileinfo()
350 fid->purge_cache = false; in cifs_new_fileinfo()
351 server->ops->set_fid(cfile, fid, oplock); in cifs_new_fileinfo()
353 list_add(&cfile->tlist, &tcon->openFileList); in cifs_new_fileinfo()
354 atomic_inc(&tcon->num_local_opens); in cifs_new_fileinfo()
357 spin_lock(&cinode->open_file_lock); in cifs_new_fileinfo()
358 if (file->f_mode & FMODE_READ) in cifs_new_fileinfo()
359 list_add(&cfile->flist, &cinode->openFileList); in cifs_new_fileinfo()
361 list_add_tail(&cfile->flist, &cinode->openFileList); in cifs_new_fileinfo()
362 spin_unlock(&cinode->open_file_lock); in cifs_new_fileinfo()
363 spin_unlock(&tcon->open_file_lock); in cifs_new_fileinfo()
365 if (fid->purge_cache) in cifs_new_fileinfo()
368 file->private_data = cfile; in cifs_new_fileinfo()
375 spin_lock(&cifs_file->file_info_lock); in cifsFileInfo_get()
377 spin_unlock(&cifs_file->file_info_lock); in cifsFileInfo_get()
383 struct inode *inode = d_inode(cifs_file->dentry); in cifsFileInfo_put_final()
386 struct super_block *sb = inode->i_sb; in cifsFileInfo_put_final()
392 cifs_down_write(&cifsi->lock_sem); in cifsFileInfo_put_final()
393 list_for_each_entry_safe(li, tmp, &cifs_file->llist->locks, llist) { in cifsFileInfo_put_final()
394 list_del(&li->llist); in cifsFileInfo_put_final()
398 list_del(&cifs_file->llist->llist); in cifsFileInfo_put_final()
399 kfree(cifs_file->llist); in cifsFileInfo_put_final()
400 up_write(&cifsi->lock_sem); in cifsFileInfo_put_final()
402 cifs_put_tlink(cifs_file->tlink); in cifsFileInfo_put_final()
403 dput(cifs_file->dentry); in cifsFileInfo_put_final()
417 * cifsFileInfo_put - release a reference of file priv data
427 * _cifsFileInfo_put - release a reference of file priv data
430 * server. Must be called without holding tcon->open_file_lock,
431 * cinode->open_file_lock and cifs_file->file_info_lock.
442 struct inode *inode = d_inode(cifs_file->dentry); in _cifsFileInfo_put()
443 struct cifs_tcon *tcon = tlink_tcon(cifs_file->tlink); in _cifsFileInfo_put() local
444 struct TCP_Server_Info *server = tcon->ses->server; in _cifsFileInfo_put()
446 struct super_block *sb = inode->i_sb; in _cifsFileInfo_put()
452 spin_lock(&tcon->open_file_lock); in _cifsFileInfo_put()
453 spin_lock(&cifsi->open_file_lock); in _cifsFileInfo_put()
454 spin_lock(&cifs_file->file_info_lock); in _cifsFileInfo_put()
455 if (--cifs_file->count > 0) { in _cifsFileInfo_put()
456 spin_unlock(&cifs_file->file_info_lock); in _cifsFileInfo_put()
457 spin_unlock(&cifsi->open_file_lock); in _cifsFileInfo_put()
458 spin_unlock(&tcon->open_file_lock); in _cifsFileInfo_put()
461 spin_unlock(&cifs_file->file_info_lock); in _cifsFileInfo_put()
463 if (server->ops->get_lease_key) in _cifsFileInfo_put()
464 server->ops->get_lease_key(inode, &fid); in _cifsFileInfo_put()
467 cifs_add_pending_open_locked(&fid, cifs_file->tlink, &open); in _cifsFileInfo_put()
470 list_del(&cifs_file->flist); in _cifsFileInfo_put()
471 list_del(&cifs_file->tlist); in _cifsFileInfo_put()
472 atomic_dec(&tcon->num_local_opens); in _cifsFileInfo_put()
474 if (list_empty(&cifsi->openFileList)) { in _cifsFileInfo_put()
476 d_inode(cifs_file->dentry)); in _cifsFileInfo_put()
482 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) in _cifsFileInfo_put()
483 set_bit(CIFS_INO_INVALID_MAPPING, &cifsi->flags); in _cifsFileInfo_put()
487 spin_unlock(&cifsi->open_file_lock); in _cifsFileInfo_put()
488 spin_unlock(&tcon->open_file_lock); in _cifsFileInfo_put()
491 cancel_work_sync(&cifs_file->oplock_break) : false; in _cifsFileInfo_put()
493 if (!tcon->need_reconnect && !cifs_file->invalidHandle) { in _cifsFileInfo_put()
494 struct TCP_Server_Info *server = tcon->ses->server; in _cifsFileInfo_put()
498 if (server->ops->close_getattr) in _cifsFileInfo_put()
499 server->ops->close_getattr(xid, tcon, cifs_file); in _cifsFileInfo_put()
500 else if (server->ops->close) in _cifsFileInfo_put()
501 server->ops->close(xid, tcon, &cifs_file->fid); in _cifsFileInfo_put()
511 queue_work(fileinfo_put_wq, &cifs_file->put); in _cifsFileInfo_put()
519 int rc = -EACCES; in cifs_open()
524 struct cifs_tcon *tcon; in cifs_open() local
534 cifs_sb = CIFS_SB(inode->i_sb); in cifs_open()
540 tcon = tlink_tcon(tlink); in cifs_open()
541 server = tcon->ses->server; in cifs_open()
545 rc = -ENOMEM; in cifs_open()
550 inode, file->f_flags, full_path); in cifs_open()
552 if (file->f_flags & O_DIRECT && in cifs_open()
553 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) { in cifs_open()
554 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) in cifs_open()
555 file->f_op = &cifs_file_direct_nobrl_ops; in cifs_open()
557 file->f_op = &cifs_file_direct_ops; in cifs_open()
560 if (server->oplocks) in cifs_open()
565 if (!tcon->broken_posix_open && tcon->unix_ext && in cifs_open()
566 cap_unix(tcon->ses) && (CIFS_UNIX_POSIX_PATH_OPS_CAP & in cifs_open()
567 le64_to_cpu(tcon->fsUnixInfo.Capability))) { in cifs_open()
569 rc = cifs_posix_open(full_path, &inode, inode->i_sb, in cifs_open()
570 cifs_sb->mnt_file_mode /* ignored */, in cifs_open()
571 file->f_flags, &oplock, &fid.netfid, xid); in cifs_open()
575 } else if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { in cifs_open()
576 if (tcon->ses->serverNOS) in cifs_open()
578 tcon->ses->serverName, in cifs_open()
579 tcon->ses->serverNOS); in cifs_open()
580 tcon->broken_posix_open = true; in cifs_open()
581 } else if ((rc != -EIO) && (rc != -EREMOTE) && in cifs_open()
582 (rc != -EOPNOTSUPP)) /* path not found or net err */ in cifs_open()
590 if (server->ops->get_lease_key) in cifs_open()
591 server->ops->get_lease_key(inode, &fid); in cifs_open()
596 if (server->ops->get_lease_key) in cifs_open()
597 server->ops->get_lease_key(inode, &fid); in cifs_open()
599 rc = cifs_nt_open(full_path, inode, cifs_sb, tcon, in cifs_open()
600 file->f_flags, &oplock, &fid, xid); in cifs_open()
609 if (server->ops->close) in cifs_open()
610 server->ops->close(xid, tcon, &fid); in cifs_open()
612 rc = -ENOMEM; in cifs_open()
618 if ((oplock & CIFS_CREATE_ACTION) && !posix_open_ok && tcon->unix_ext) { in cifs_open()
621 * problems creating new read-only files. in cifs_open()
624 .mode = inode->i_mode, in cifs_open()
632 CIFSSMBUnixSetFileInfo(xid, tcon, &args, fid.netfid, in cifs_open()
633 cfile->pid); in cifs_open()
652 struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb); in cifs_relock_file()
653 struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry)); in cifs_relock_file()
654 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); in cifs_relock_file() local
657 down_read_nested(&cinode->lock_sem, SINGLE_DEPTH_NESTING); in cifs_relock_file()
658 if (cinode->can_cache_brlcks) { in cifs_relock_file()
659 /* can cache locks - no need to relock */ in cifs_relock_file()
660 up_read(&cinode->lock_sem); in cifs_relock_file()
664 if (cap_unix(tcon->ses) && in cifs_relock_file()
665 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && in cifs_relock_file()
666 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) in cifs_relock_file()
669 rc = tcon->ses->server->ops->push_mand_locks(cfile); in cifs_relock_file()
671 up_read(&cinode->lock_sem); in cifs_relock_file()
678 int rc = -EACCES; in cifs_reopen_file()
682 struct cifs_tcon *tcon; in cifs_reopen_file() local
693 mutex_lock(&cfile->fh_mutex); in cifs_reopen_file()
694 if (!cfile->invalidHandle) { in cifs_reopen_file()
695 mutex_unlock(&cfile->fh_mutex); in cifs_reopen_file()
701 inode = d_inode(cfile->dentry); in cifs_reopen_file()
702 cifs_sb = CIFS_SB(inode->i_sb); in cifs_reopen_file()
703 tcon = tlink_tcon(cfile->tlink); in cifs_reopen_file()
704 server = tcon->ses->server; in cifs_reopen_file()
712 full_path = build_path_from_dentry(cfile->dentry); in cifs_reopen_file()
714 rc = -ENOMEM; in cifs_reopen_file()
715 mutex_unlock(&cfile->fh_mutex); in cifs_reopen_file()
721 inode, cfile->f_flags, full_path); in cifs_reopen_file()
723 if (tcon->ses->server->oplocks) in cifs_reopen_file()
728 if (tcon->unix_ext && cap_unix(tcon->ses) && in cifs_reopen_file()
730 le64_to_cpu(tcon->fsUnixInfo.Capability))) { in cifs_reopen_file()
735 unsigned int oflags = cfile->f_flags & in cifs_reopen_file()
738 rc = cifs_posix_open(full_path, NULL, inode->i_sb, in cifs_reopen_file()
739 cifs_sb->mnt_file_mode /* ignored */, in cifs_reopen_file()
740 oflags, &oplock, &cfile->fid.netfid, xid); in cifs_reopen_file()
752 desired_access = cifs_convert_flags(cfile->f_flags); in cifs_reopen_file()
755 if (cfile->f_flags & O_SYNC) in cifs_reopen_file()
758 if (cfile->f_flags & O_DIRECT) in cifs_reopen_file()
761 if (server->ops->get_lease_key) in cifs_reopen_file()
762 server->ops->get_lease_key(inode, &cfile->fid); in cifs_reopen_file()
764 oparms.tcon = tcon; in cifs_reopen_file()
770 oparms.fid = &cfile->fid; in cifs_reopen_file()
775 * ops->open and then calling get_inode_info with returned buf since in cifs_reopen_file()
780 rc = server->ops->open(xid, &oparms, &oplock, NULL); in cifs_reopen_file()
781 if (rc == -ENOENT && oparms.reconnect == false) { in cifs_reopen_file()
782 /* durable handle timeout is expired - open the file again */ in cifs_reopen_file()
783 rc = server->ops->open(xid, &oparms, &oplock, NULL); in cifs_reopen_file()
789 mutex_unlock(&cfile->fh_mutex); in cifs_reopen_file()
796 cfile->invalidHandle = false; in cifs_reopen_file()
797 mutex_unlock(&cfile->fh_mutex); in cifs_reopen_file()
801 rc = filemap_write_and_wait(inode->i_mapping); in cifs_reopen_file()
803 mapping_set_error(inode->i_mapping, rc); in cifs_reopen_file()
805 if (tcon->posix_extensions) in cifs_reopen_file()
806 rc = smb311_posix_get_inode_info(&inode, full_path, inode->i_sb, xid); in cifs_reopen_file()
807 else if (tcon->unix_ext) in cifs_reopen_file()
809 inode->i_sb, xid); in cifs_reopen_file()
812 inode->i_sb, xid, NULL); in cifs_reopen_file()
825 if (server->ops->is_read_op(oplock) && cifs_has_mand_locks(cinode)) { in cifs_reopen_file()
830 server->ops->set_fid(cfile, &cfile->fid, oplock); in cifs_reopen_file()
842 if (file->private_data != NULL) { in cifs_close()
843 _cifsFileInfo_put(file->private_data, true, false); in cifs_close()
844 file->private_data = NULL; in cifs_close()
847 /* return code from the ->release op is always ignored */ in cifs_close()
852 cifs_reopen_persistent_handles(struct cifs_tcon *tcon) in cifs_reopen_persistent_handles() argument
859 if (!tcon->use_persistent || !tcon->need_reopen_files) in cifs_reopen_persistent_handles()
862 tcon->need_reopen_files = false; in cifs_reopen_persistent_handles()
868 spin_lock(&tcon->open_file_lock); in cifs_reopen_persistent_handles()
869 list_for_each(tmp, &tcon->openFileList) { in cifs_reopen_persistent_handles()
871 if (!open_file->invalidHandle) in cifs_reopen_persistent_handles()
874 list_add_tail(&open_file->rlist, &tmp_list); in cifs_reopen_persistent_handles()
876 spin_unlock(&tcon->open_file_lock); in cifs_reopen_persistent_handles()
881 tcon->need_reopen_files = true; in cifs_reopen_persistent_handles()
882 list_del_init(&open_file->rlist); in cifs_reopen_persistent_handles()
891 struct cifsFileInfo *cfile = file->private_data; in cifs_closedir()
892 struct cifs_tcon *tcon; in cifs_closedir() local
902 tcon = tlink_tcon(cfile->tlink); in cifs_closedir()
903 server = tcon->ses->server; in cifs_closedir()
906 spin_lock(&cfile->file_info_lock); in cifs_closedir()
907 if (server->ops->dir_needs_close(cfile)) { in cifs_closedir()
908 cfile->invalidHandle = true; in cifs_closedir()
909 spin_unlock(&cfile->file_info_lock); in cifs_closedir()
910 if (server->ops->close_dir) in cifs_closedir()
911 rc = server->ops->close_dir(xid, tcon, &cfile->fid); in cifs_closedir()
913 rc = -ENOSYS; in cifs_closedir()
918 spin_unlock(&cfile->file_info_lock); in cifs_closedir()
920 buf = cfile->srch_inf.ntwrk_buf_start; in cifs_closedir()
923 cfile->srch_inf.ntwrk_buf_start = NULL; in cifs_closedir()
924 if (cfile->srch_inf.smallBuf) in cifs_closedir()
930 cifs_put_tlink(cfile->tlink); in cifs_closedir()
931 kfree(file->private_data); in cifs_closedir()
932 file->private_data = NULL; in cifs_closedir()
945 lock->offset = offset; in cifs_lock_init()
946 lock->length = length; in cifs_lock_init()
947 lock->type = type; in cifs_lock_init()
948 lock->pid = current->tgid; in cifs_lock_init()
949 lock->flags = flags; in cifs_lock_init()
950 INIT_LIST_HEAD(&lock->blist); in cifs_lock_init()
951 init_waitqueue_head(&lock->block_q); in cifs_lock_init()
959 list_for_each_entry_safe(li, tmp, &lock->blist, blist) { in cifs_del_lock_waiters()
960 list_del_init(&li->blist); in cifs_del_lock_waiters()
961 wake_up(&li->block_q); in cifs_del_lock_waiters()
969 /* @rw_check : 0 - no op, 1 - read, 2 - write */
977 struct cifsFileInfo *cur_cfile = fdlocks->cfile; in cifs_find_fid_lock_conflict()
978 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server; in cifs_find_fid_lock_conflict()
980 list_for_each_entry(li, &fdlocks->locks, llist) { in cifs_find_fid_lock_conflict()
981 if (offset + length <= li->offset || in cifs_find_fid_lock_conflict()
982 offset >= li->offset + li->length) in cifs_find_fid_lock_conflict()
984 if (rw_check != CIFS_LOCK_OP && current->tgid == li->pid && in cifs_find_fid_lock_conflict()
985 server->ops->compare_fids(cfile, cur_cfile)) { in cifs_find_fid_lock_conflict()
987 if (!(li->type & server->vals->shared_lock_type) || in cifs_find_fid_lock_conflict()
991 if ((type & server->vals->shared_lock_type) && in cifs_find_fid_lock_conflict()
992 ((server->ops->compare_fids(cfile, cur_cfile) && in cifs_find_fid_lock_conflict()
993 current->tgid == li->pid) || type == li->type)) in cifs_find_fid_lock_conflict()
996 (flags & FL_OFDLCK) && (li->flags & FL_OFDLCK) && in cifs_find_fid_lock_conflict()
997 server->ops->compare_fids(cfile, cur_cfile)) in cifs_find_fid_lock_conflict()
1013 struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry)); in cifs_find_lock_conflict()
1015 list_for_each_entry(cur, &cinode->llist, llist) { in cifs_find_lock_conflict()
1039 struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry)); in cifs_lock_test()
1040 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server; in cifs_lock_test()
1043 down_read(&cinode->lock_sem); in cifs_lock_test()
1046 flock->fl_flags, &conf_lock, in cifs_lock_test()
1049 flock->fl_start = conf_lock->offset; in cifs_lock_test()
1050 flock->fl_end = conf_lock->offset + conf_lock->length - 1; in cifs_lock_test()
1051 flock->fl_pid = conf_lock->pid; in cifs_lock_test()
1052 if (conf_lock->type & server->vals->shared_lock_type) in cifs_lock_test()
1053 flock->fl_type = F_RDLCK; in cifs_lock_test()
1055 flock->fl_type = F_WRLCK; in cifs_lock_test()
1056 } else if (!cinode->can_cache_brlcks) in cifs_lock_test()
1059 flock->fl_type = F_UNLCK; in cifs_lock_test()
1061 up_read(&cinode->lock_sem); in cifs_lock_test()
1068 struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry)); in cifs_lock_add()
1069 cifs_down_write(&cinode->lock_sem); in cifs_lock_add()
1070 list_add_tail(&lock->llist, &cfile->llist->locks); in cifs_lock_add()
1071 up_write(&cinode->lock_sem); in cifs_lock_add()
1075 * Set the byte-range lock (mandatory style). Returns:
1078 * 3) -EACCES, if there is a lock that prevents us and wait is false.
1085 struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry)); in cifs_lock_add_if()
1091 cifs_down_write(&cinode->lock_sem); in cifs_lock_add_if()
1093 exist = cifs_find_lock_conflict(cfile, lock->offset, lock->length, in cifs_lock_add_if()
1094 lock->type, lock->flags, &conf_lock, in cifs_lock_add_if()
1096 if (!exist && cinode->can_cache_brlcks) { in cifs_lock_add_if()
1097 list_add_tail(&lock->llist, &cfile->llist->locks); in cifs_lock_add_if()
1098 up_write(&cinode->lock_sem); in cifs_lock_add_if()
1105 rc = -EACCES; in cifs_lock_add_if()
1107 list_add_tail(&lock->blist, &conf_lock->blist); in cifs_lock_add_if()
1108 up_write(&cinode->lock_sem); in cifs_lock_add_if()
1109 rc = wait_event_interruptible(lock->block_q, in cifs_lock_add_if()
1110 (lock->blist.prev == &lock->blist) && in cifs_lock_add_if()
1111 (lock->blist.next == &lock->blist)); in cifs_lock_add_if()
1114 cifs_down_write(&cinode->lock_sem); in cifs_lock_add_if()
1115 list_del_init(&lock->blist); in cifs_lock_add_if()
1118 up_write(&cinode->lock_sem); in cifs_lock_add_if()
1134 unsigned char saved_type = flock->fl_type; in cifs_posix_lock_test()
1136 if ((flock->fl_flags & FL_POSIX) == 0) in cifs_posix_lock_test()
1139 down_read(&cinode->lock_sem); in cifs_posix_lock_test()
1142 if (flock->fl_type == F_UNLCK && !cinode->can_cache_brlcks) { in cifs_posix_lock_test()
1143 flock->fl_type = saved_type; in cifs_posix_lock_test()
1147 up_read(&cinode->lock_sem); in cifs_posix_lock_test()
1152 * Set the byte-range lock (posix style). Returns:
1164 if ((flock->fl_flags & FL_POSIX) == 0) in cifs_posix_lock_set()
1167 cifs_down_write(&cinode->lock_sem); in cifs_posix_lock_set()
1168 if (!cinode->can_cache_brlcks) { in cifs_posix_lock_set()
1169 up_write(&cinode->lock_sem); in cifs_posix_lock_set()
1174 up_write(&cinode->lock_sem); in cifs_posix_lock_set()
1184 struct cifs_tcon *tcon; in cifs_push_mandatory_locks() local
1194 tcon = tlink_tcon(cfile->tlink); in cifs_push_mandatory_locks()
1197 * Accessing maxBuf is racy with cifs_reconnect - need to store value in cifs_push_mandatory_locks()
1200 max_buf = tcon->ses->server->maxBuf; in cifs_push_mandatory_locks()
1203 return -EINVAL; in cifs_push_mandatory_locks()
1208 max_buf = min_t(unsigned int, max_buf - sizeof(struct smb_hdr), in cifs_push_mandatory_locks()
1210 max_num = (max_buf - sizeof(struct smb_hdr)) / in cifs_push_mandatory_locks()
1215 return -ENOMEM; in cifs_push_mandatory_locks()
1221 list_for_each_entry_safe(li, tmp, &cfile->llist->locks, llist) { in cifs_push_mandatory_locks()
1222 if (li->type != types[i]) in cifs_push_mandatory_locks()
1224 cur->Pid = cpu_to_le16(li->pid); in cifs_push_mandatory_locks()
1225 cur->LengthLow = cpu_to_le32((u32)li->length); in cifs_push_mandatory_locks()
1226 cur->LengthHigh = cpu_to_le32((u32)(li->length>>32)); in cifs_push_mandatory_locks()
1227 cur->OffsetLow = cpu_to_le32((u32)li->offset); in cifs_push_mandatory_locks()
1228 cur->OffsetHigh = cpu_to_le32((u32)(li->offset>>32)); in cifs_push_mandatory_locks()
1230 stored_rc = cifs_lockv(xid, tcon, in cifs_push_mandatory_locks()
1231 cfile->fid.netfid, in cifs_push_mandatory_locks()
1232 (__u8)li->type, 0, num, in cifs_push_mandatory_locks()
1243 stored_rc = cifs_lockv(xid, tcon, cfile->fid.netfid, in cifs_push_mandatory_locks()
1273 struct inode *inode = d_inode(cfile->dentry); in cifs_push_posix_locks()
1274 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); in cifs_push_posix_locks() local
1276 struct file_lock_context *flctx = inode->i_flctx; in cifs_push_posix_locks()
1288 spin_lock(&flctx->flc_lock); in cifs_push_posix_locks()
1289 list_for_each(el, &flctx->flc_posix) { in cifs_push_posix_locks()
1292 spin_unlock(&flctx->flc_lock); in cifs_push_posix_locks()
1298 * added to the list while we are holding cinode->lock_sem that in cifs_push_posix_locks()
1304 rc = -ENOMEM; in cifs_push_posix_locks()
1307 list_add_tail(&lck->llist, &locks_to_send); in cifs_push_posix_locks()
1311 spin_lock(&flctx->flc_lock); in cifs_push_posix_locks()
1312 list_for_each_entry(flock, &flctx->flc_posix, fl_list) { in cifs_push_posix_locks()
1316 * structures - something is really wrong. in cifs_push_posix_locks()
1321 length = 1 + flock->fl_end - flock->fl_start; in cifs_push_posix_locks()
1322 if (flock->fl_type == F_RDLCK || flock->fl_type == F_SHLCK) in cifs_push_posix_locks()
1327 lck->pid = hash_lockowner(flock->fl_owner); in cifs_push_posix_locks()
1328 lck->netfid = cfile->fid.netfid; in cifs_push_posix_locks()
1329 lck->length = length; in cifs_push_posix_locks()
1330 lck->type = type; in cifs_push_posix_locks()
1331 lck->offset = flock->fl_start; in cifs_push_posix_locks()
1333 spin_unlock(&flctx->flc_lock); in cifs_push_posix_locks()
1338 stored_rc = CIFSSMBPosixLock(xid, tcon, lck->netfid, lck->pid, in cifs_push_posix_locks()
1339 lck->offset, lck->length, NULL, in cifs_push_posix_locks()
1340 lck->type, 0); in cifs_push_posix_locks()
1343 list_del(&lck->llist); in cifs_push_posix_locks()
1352 list_del(&lck->llist); in cifs_push_posix_locks()
1361 struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb); in cifs_push_locks()
1362 struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry)); in cifs_push_locks()
1363 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); in cifs_push_locks() local
1366 /* we are going to update can_cache_brlcks here - need a write access */ in cifs_push_locks()
1367 cifs_down_write(&cinode->lock_sem); in cifs_push_locks()
1368 if (!cinode->can_cache_brlcks) { in cifs_push_locks()
1369 up_write(&cinode->lock_sem); in cifs_push_locks()
1373 if (cap_unix(tcon->ses) && in cifs_push_locks()
1374 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && in cifs_push_locks()
1375 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) in cifs_push_locks()
1378 rc = tcon->ses->server->ops->push_mand_locks(cfile); in cifs_push_locks()
1380 cinode->can_cache_brlcks = false; in cifs_push_locks()
1381 up_write(&cinode->lock_sem); in cifs_push_locks()
1389 if (flock->fl_flags & FL_POSIX) in cifs_read_flock()
1391 if (flock->fl_flags & FL_FLOCK) in cifs_read_flock()
1393 if (flock->fl_flags & FL_SLEEP) { in cifs_read_flock()
1397 if (flock->fl_flags & FL_ACCESS) in cifs_read_flock()
1398 cifs_dbg(FYI, "Process suspended by mandatory locking - not implemented yet\n"); in cifs_read_flock()
1399 if (flock->fl_flags & FL_LEASE) in cifs_read_flock()
1400 cifs_dbg(FYI, "Lease on file - not implemented yet\n"); in cifs_read_flock()
1401 if (flock->fl_flags & in cifs_read_flock()
1404 cifs_dbg(FYI, "Unknown lock flags 0x%x\n", flock->fl_flags); in cifs_read_flock()
1406 *type = server->vals->large_lock_type; in cifs_read_flock()
1407 if (flock->fl_type == F_WRLCK) { in cifs_read_flock()
1409 *type |= server->vals->exclusive_lock_type; in cifs_read_flock()
1411 } else if (flock->fl_type == F_UNLCK) { in cifs_read_flock()
1413 *type |= server->vals->unlock_lock_type; in cifs_read_flock()
1416 } else if (flock->fl_type == F_RDLCK) { in cifs_read_flock()
1418 *type |= server->vals->shared_lock_type; in cifs_read_flock()
1420 } else if (flock->fl_type == F_EXLCK) { in cifs_read_flock()
1422 *type |= server->vals->exclusive_lock_type; in cifs_read_flock()
1424 } else if (flock->fl_type == F_SHLCK) { in cifs_read_flock()
1426 *type |= server->vals->shared_lock_type; in cifs_read_flock()
1437 __u64 length = 1 + flock->fl_end - flock->fl_start; in cifs_getlk()
1438 struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data; in cifs_getlk()
1439 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); in cifs_getlk() local
1440 struct TCP_Server_Info *server = tcon->ses->server; in cifs_getlk()
1441 __u16 netfid = cfile->fid.netfid; in cifs_getlk()
1450 if (type & server->vals->shared_lock_type) in cifs_getlk()
1454 rc = CIFSSMBPosixLock(xid, tcon, netfid, in cifs_getlk()
1455 hash_lockowner(flock->fl_owner), in cifs_getlk()
1456 flock->fl_start, length, flock, in cifs_getlk()
1461 rc = cifs_lock_test(cfile, flock->fl_start, length, type, flock); in cifs_getlk()
1466 rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, type, in cifs_getlk()
1469 rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, in cifs_getlk()
1471 flock->fl_type = F_UNLCK; in cifs_getlk()
1478 if (type & server->vals->shared_lock_type) { in cifs_getlk()
1479 flock->fl_type = F_WRLCK; in cifs_getlk()
1483 type &= ~server->vals->exclusive_lock_type; in cifs_getlk()
1485 rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, in cifs_getlk()
1486 type | server->vals->shared_lock_type, in cifs_getlk()
1489 rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, in cifs_getlk()
1490 type | server->vals->shared_lock_type, 0, 1, false); in cifs_getlk()
1491 flock->fl_type = F_RDLCK; in cifs_getlk()
1496 flock->fl_type = F_WRLCK; in cifs_getlk()
1515 list_del(&li->llist); in cifs_free_llist()
1532 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); in cifs_unlock_range() local
1533 struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry)); in cifs_unlock_range()
1535 __u64 length = 1 + flock->fl_end - flock->fl_start; in cifs_unlock_range()
1541 * Accessing maxBuf is racy with cifs_reconnect - need to store value in cifs_unlock_range()
1544 max_buf = tcon->ses->server->maxBuf; in cifs_unlock_range()
1546 return -EINVAL; in cifs_unlock_range()
1550 max_buf = min_t(unsigned int, max_buf - sizeof(struct smb_hdr), in cifs_unlock_range()
1552 max_num = (max_buf - sizeof(struct smb_hdr)) / in cifs_unlock_range()
1556 return -ENOMEM; in cifs_unlock_range()
1558 cifs_down_write(&cinode->lock_sem); in cifs_unlock_range()
1562 list_for_each_entry_safe(li, tmp, &cfile->llist->locks, llist) { in cifs_unlock_range()
1563 if (flock->fl_start > li->offset || in cifs_unlock_range()
1564 (flock->fl_start + length) < in cifs_unlock_range()
1565 (li->offset + li->length)) in cifs_unlock_range()
1567 if (current->tgid != li->pid) in cifs_unlock_range()
1569 if (types[i] != li->type) in cifs_unlock_range()
1571 if (cinode->can_cache_brlcks) { in cifs_unlock_range()
1573 * We can cache brlock requests - simply remove in cifs_unlock_range()
1576 list_del(&li->llist); in cifs_unlock_range()
1581 cur->Pid = cpu_to_le16(li->pid); in cifs_unlock_range()
1582 cur->LengthLow = cpu_to_le32((u32)li->length); in cifs_unlock_range()
1583 cur->LengthHigh = cpu_to_le32((u32)(li->length>>32)); in cifs_unlock_range()
1584 cur->OffsetLow = cpu_to_le32((u32)li->offset); in cifs_unlock_range()
1585 cur->OffsetHigh = cpu_to_le32((u32)(li->offset>>32)); in cifs_unlock_range()
1591 list_move(&li->llist, &tmp_llist); in cifs_unlock_range()
1593 stored_rc = cifs_lockv(xid, tcon, in cifs_unlock_range()
1594 cfile->fid.netfid, in cifs_unlock_range()
1595 li->type, num, 0, buf); in cifs_unlock_range()
1599 * request - add all locks from the tmp in cifs_unlock_range()
1603 &cfile->llist->locks); in cifs_unlock_range()
1607 * The unlock range request succeed - in cifs_unlock_range()
1617 stored_rc = cifs_lockv(xid, tcon, cfile->fid.netfid, in cifs_unlock_range()
1621 &cfile->llist->locks); in cifs_unlock_range()
1628 up_write(&cinode->lock_sem); in cifs_unlock_range()
1639 __u64 length = 1 + flock->fl_end - flock->fl_start; in cifs_setlk()
1640 struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data; in cifs_setlk()
1641 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); in cifs_setlk() local
1642 struct TCP_Server_Info *server = tcon->ses->server; in cifs_setlk()
1643 struct inode *inode = d_inode(cfile->dentry); in cifs_setlk()
1652 if (type & server->vals->shared_lock_type) in cifs_setlk()
1660 rc = CIFSSMBPosixLock(xid, tcon, cfile->fid.netfid, in cifs_setlk()
1661 hash_lockowner(flock->fl_owner), in cifs_setlk()
1662 flock->fl_start, length, in cifs_setlk()
1670 lock = cifs_lock_init(flock->fl_start, length, type, in cifs_setlk()
1671 flock->fl_flags); in cifs_setlk()
1673 return -ENOMEM; in cifs_setlk()
1685 * if we set a byte-range lock on a file - break it explicitly in cifs_setlk()
1687 * read won't conflict with non-overlapted locks due to in cifs_setlk()
1695 CIFS_I(inode)->oplock = 0; in cifs_setlk()
1698 rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, in cifs_setlk()
1707 rc = server->ops->mand_unlock_range(cfile, flock, xid); in cifs_setlk()
1710 if ((flock->fl_flags & FL_POSIX) || (flock->fl_flags & FL_FLOCK)) { in cifs_setlk()
1719 if (!(flock->fl_flags & FL_CLOSE)) in cifs_setlk()
1734 struct cifs_tcon *tcon; in cifs_flock() local
1740 if (!(fl->fl_flags & FL_FLOCK)) { in cifs_flock()
1741 rc = -ENOLCK; in cifs_flock()
1746 cfile = (struct cifsFileInfo *)file->private_data; in cifs_flock()
1747 tcon = tlink_tcon(cfile->tlink); in cifs_flock()
1750 tcon->ses->server); in cifs_flock()
1753 if (cap_unix(tcon->ses) && in cifs_flock()
1754 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && in cifs_flock()
1755 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) in cifs_flock()
1763 rc = -EOPNOTSUPP; in cifs_flock()
1783 struct cifs_tcon *tcon; in cifs_lock() local
1787 rc = -EACCES; in cifs_lock()
1791 cmd, flock->fl_flags, flock->fl_type, in cifs_lock()
1792 flock->fl_start, flock->fl_end); in cifs_lock()
1794 cfile = (struct cifsFileInfo *)file->private_data; in cifs_lock()
1795 tcon = tlink_tcon(cfile->tlink); in cifs_lock()
1798 tcon->ses->server); in cifs_lock()
1801 if (cap_unix(tcon->ses) && in cifs_lock()
1802 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && in cifs_lock()
1803 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) in cifs_lock()
1821 return -EOPNOTSUPP; in cifs_lock()
1832 * the inode->i_lock held
1840 if (end_of_write > cifsi->server_eof) in cifs_update_eof()
1841 cifsi->server_eof = end_of_write; in cifs_update_eof()
1851 struct cifs_tcon *tcon; in cifs_write() local
1854 struct dentry *dentry = open_file->dentry; in cifs_write()
1861 tcon = tlink_tcon(open_file->tlink); in cifs_write()
1862 server = tcon->ses->server; in cifs_write()
1864 if (!server->ops->sync_write) in cifs_write()
1865 return -ENOSYS; in cifs_write()
1871 rc = -EAGAIN; in cifs_write()
1872 while (rc == -EAGAIN) { in cifs_write()
1876 if (open_file->invalidHandle) { in cifs_write()
1886 len = min(server->ops->wp_retry_size(d_inode(dentry)), in cifs_write()
1887 (unsigned int)write_size - total_written); in cifs_write()
1892 io_parms.tcon = tcon; in cifs_write()
1895 rc = server->ops->sync_write(xid, &open_file->fid, in cifs_write()
1906 spin_lock(&d_inode(dentry)->i_lock); in cifs_write()
1908 spin_unlock(&d_inode(dentry)->i_lock); in cifs_write()
1913 cifs_stats_bytes_written(tcon, total_written); in cifs_write()
1916 spin_lock(&d_inode(dentry)->i_lock); in cifs_write()
1917 if (*offset > d_inode(dentry)->i_size) in cifs_write()
1919 spin_unlock(&d_inode(dentry)->i_lock); in cifs_write()
1930 struct cifs_sb_info *cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb); in find_readable_file()
1933 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)) in find_readable_file()
1936 spin_lock(&cifs_inode->open_file_lock); in find_readable_file()
1937 /* we could simply get the first_list_entry since write-only entries in find_readable_file()
1940 list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { in find_readable_file()
1941 if (fsuid_only && !uid_eq(open_file->uid, current_fsuid())) in find_readable_file()
1943 if (OPEN_FMODE(open_file->f_flags) & FMODE_READ) { in find_readable_file()
1944 if (!open_file->invalidHandle) { in find_readable_file()
1948 spin_unlock(&cifs_inode->open_file_lock); in find_readable_file()
1956 spin_unlock(&cifs_inode->open_file_lock); in find_readable_file()
1960 /* Return -EBADF if no handle is found and general rc otherwise */
1968 int rc = -EBADF; in cifs_get_writable_file()
1975 * Having a null inode here (because mapping->host was set to zero by in cifs_get_writable_file()
1986 cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb); in cifs_get_writable_file()
1989 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)) in cifs_get_writable_file()
1992 spin_lock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
1995 spin_unlock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
1998 list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { in cifs_get_writable_file()
1999 if (!any_available && open_file->pid != current->tgid) in cifs_get_writable_file()
2001 if (fsuid_only && !uid_eq(open_file->uid, current_fsuid())) in cifs_get_writable_file()
2003 if (with_delete && !(open_file->fid.access & DELETE)) in cifs_get_writable_file()
2005 if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) { in cifs_get_writable_file()
2006 if (!open_file->invalidHandle) { in cifs_get_writable_file()
2009 spin_unlock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
2029 spin_unlock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
2038 spin_lock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
2039 list_move_tail(&inv_file->flist, &cifs_inode->openFileList); in cifs_get_writable_file()
2040 spin_unlock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
2044 spin_lock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
2065 cifs_get_writable_path(struct cifs_tcon *tcon, const char *name, in cifs_get_writable_path() argument
2076 spin_lock(&tcon->open_file_lock); in cifs_get_writable_path()
2077 list_for_each(tmp, &tcon->openFileList) { in cifs_get_writable_path()
2080 full_path = build_path_from_dentry(cfile->dentry); in cifs_get_writable_path()
2082 spin_unlock(&tcon->open_file_lock); in cifs_get_writable_path()
2083 return -ENOMEM; in cifs_get_writable_path()
2091 cinode = CIFS_I(d_inode(cfile->dentry)); in cifs_get_writable_path()
2092 spin_unlock(&tcon->open_file_lock); in cifs_get_writable_path()
2096 spin_unlock(&tcon->open_file_lock); in cifs_get_writable_path()
2097 return -ENOENT; in cifs_get_writable_path()
2101 cifs_get_readable_path(struct cifs_tcon *tcon, const char *name, in cifs_get_readable_path() argument
2111 spin_lock(&tcon->open_file_lock); in cifs_get_readable_path()
2112 list_for_each(tmp, &tcon->openFileList) { in cifs_get_readable_path()
2115 full_path = build_path_from_dentry(cfile->dentry); in cifs_get_readable_path()
2117 spin_unlock(&tcon->open_file_lock); in cifs_get_readable_path()
2118 return -ENOMEM; in cifs_get_readable_path()
2126 cinode = CIFS_I(d_inode(cfile->dentry)); in cifs_get_readable_path()
2127 spin_unlock(&tcon->open_file_lock); in cifs_get_readable_path()
2129 return *ret_file ? 0 : -ENOENT; in cifs_get_readable_path()
2132 spin_unlock(&tcon->open_file_lock); in cifs_get_readable_path()
2133 return -ENOENT; in cifs_get_readable_path()
2138 struct address_space *mapping = page->mapping; in cifs_partialpagewrite()
2139 loff_t offset = (loff_t)page->index << PAGE_SHIFT; in cifs_partialpagewrite()
2141 int rc = -EFAULT; in cifs_partialpagewrite()
2146 if (!mapping || !mapping->host) in cifs_partialpagewrite()
2147 return -EFAULT; in cifs_partialpagewrite()
2149 inode = page->mapping->host; in cifs_partialpagewrite()
2157 return -EIO; in cifs_partialpagewrite()
2161 if (offset > mapping->host->i_size) { in cifs_partialpagewrite()
2167 if (mapping->host->i_size - offset < (loff_t)to) in cifs_partialpagewrite()
2168 to = (unsigned)(mapping->host->i_size - offset); in cifs_partialpagewrite()
2170 rc = cifs_get_writable_file(CIFS_I(mapping->host), FIND_WR_ANY, in cifs_partialpagewrite()
2173 bytes_written = cifs_write(open_file, open_file->pid, in cifs_partialpagewrite()
2174 write_data, to - from, &offset); in cifs_partialpagewrite()
2177 inode->i_atime = inode->i_mtime = current_time(inode); in cifs_partialpagewrite()
2183 rc = -EFAULT; in cifs_partialpagewrite()
2187 rc = -EIO; in cifs_partialpagewrite()
2207 PAGECACHE_TAG_DIRTY, tofind, wdata->pages); in wdata_alloc_and_fillpages()
2221 page = wdata->pages[i]; in wdata_prepare_pages()
2225 * (changing page->mapping to NULL), or even swizzled in wdata_prepare_pages()
2234 if (unlikely(page->mapping != mapping)) { in wdata_prepare_pages()
2239 if (!wbc->range_cyclic && page->index > end) { in wdata_prepare_pages()
2245 if (*next && (page->index != *next)) { in wdata_prepare_pages()
2251 if (wbc->sync_mode != WB_SYNC_NONE) in wdata_prepare_pages()
2265 if (page_offset(page) >= i_size_read(mapping->host)) { in wdata_prepare_pages()
2272 wdata->pages[i] = page; in wdata_prepare_pages()
2273 *next = page->index + 1; in wdata_prepare_pages()
2279 *index = wdata->pages[0]->index + 1; in wdata_prepare_pages()
2283 put_page(wdata->pages[i]); in wdata_prepare_pages()
2284 wdata->pages[i] = NULL; in wdata_prepare_pages()
2296 wdata->sync_mode = wbc->sync_mode; in wdata_send_pages()
2297 wdata->nr_pages = nr_pages; in wdata_send_pages()
2298 wdata->offset = page_offset(wdata->pages[0]); in wdata_send_pages()
2299 wdata->pagesz = PAGE_SIZE; in wdata_send_pages()
2300 wdata->tailsz = min(i_size_read(mapping->host) - in wdata_send_pages()
2301 page_offset(wdata->pages[nr_pages - 1]), in wdata_send_pages()
2303 wdata->bytes = ((nr_pages - 1) * PAGE_SIZE) + wdata->tailsz; in wdata_send_pages()
2304 wdata->pid = wdata->cfile->pid; in wdata_send_pages()
2306 rc = adjust_credits(wdata->server, &wdata->credits, wdata->bytes); in wdata_send_pages()
2310 if (wdata->cfile->invalidHandle) in wdata_send_pages()
2311 rc = -EAGAIN; in wdata_send_pages()
2313 rc = wdata->server->ops->async_writev(wdata, in wdata_send_pages()
2322 struct inode *inode = mapping->host; in cifs_writepages()
2323 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); in cifs_writepages()
2337 if (cifs_sb->wsize < PAGE_SIZE) in cifs_writepages()
2341 if (wbc->range_cyclic) { in cifs_writepages()
2342 index = mapping->writeback_index; /* Start from prev offset */ in cifs_writepages()
2343 end = -1; in cifs_writepages()
2345 index = wbc->range_start >> PAGE_SHIFT; in cifs_writepages()
2346 end = wbc->range_end >> PAGE_SHIFT; in cifs_writepages()
2347 if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) in cifs_writepages()
2351 server = cifs_pick_channel(cifs_sb_master_tcon(cifs_sb)->ses); in cifs_writepages()
2370 rc = server->ops->wait_mtu_credits(server, cifs_sb->wsize, in cifs_writepages()
2377 tofind = min((wsize / PAGE_SIZE) - 1, end - index) + 1; in cifs_writepages()
2382 rc = -ENOMEM; in cifs_writepages()
2389 kref_put(&wdata->refcount, cifs_writedata_release); in cifs_writepages()
2399 kref_put(&wdata->refcount, cifs_writedata_release); in cifs_writepages()
2404 wdata->credits = credits_on_stack; in cifs_writepages()
2405 wdata->cfile = cfile; in cifs_writepages()
2406 wdata->server = server; in cifs_writepages()
2409 if (!wdata->cfile) { in cifs_writepages()
2415 rc = -EBADF; in cifs_writepages()
2420 unlock_page(wdata->pages[i]); in cifs_writepages()
2422 /* send failure -- clean up the mess */ in cifs_writepages()
2424 add_credits_and_wake_if(server, &wdata->credits, 0); in cifs_writepages()
2428 wdata->pages[i]); in cifs_writepages()
2430 SetPageError(wdata->pages[i]); in cifs_writepages()
2431 end_page_writeback(wdata->pages[i]); in cifs_writepages()
2432 put_page(wdata->pages[i]); in cifs_writepages()
2437 kref_put(&wdata->refcount, cifs_writedata_release); in cifs_writepages()
2439 if (wbc->sync_mode == WB_SYNC_ALL && rc == -EAGAIN) { in cifs_writepages()
2453 wbc->nr_to_write -= nr_pages; in cifs_writepages()
2454 if (wbc->nr_to_write <= 0) in cifs_writepages()
2473 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) in cifs_writepages()
2474 mapping->writeback_index = index; in cifs_writepages()
2492 cifs_dbg(FYI, "ppw - page not up to date\n"); in cifs_writepage_locked()
2498 * or re-dirty the page with "redirty_page_for_writepage()" in in cifs_writepage_locked()
2501 * Just unlocking the page will cause the radix tree tag-bits in cifs_writepage_locked()
2508 if (wbc->sync_mode == WB_SYNC_ALL && rc == -EAGAIN) in cifs_writepage_locked()
2513 mapping_set_error(page->mapping, rc); in cifs_writepage_locked()
2535 struct inode *inode = mapping->host; in cifs_write_end()
2536 struct cifsFileInfo *cfile = file->private_data; in cifs_write_end()
2537 struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb); in cifs_write_end()
2540 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) in cifs_write_end()
2541 pid = cfile->pid; in cifs_write_end()
2543 pid = current->tgid; in cifs_write_end()
2557 unsigned offset = pos & (PAGE_SIZE - 1); in cifs_write_end()
2579 spin_lock(&inode->i_lock); in cifs_write_end()
2580 if (pos > inode->i_size) in cifs_write_end()
2582 spin_unlock(&inode->i_lock); in cifs_write_end()
2596 struct cifs_tcon *tcon; in cifs_strict_fsync() local
2598 struct cifsFileInfo *smbfile = file->private_data; in cifs_strict_fsync()
2600 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); in cifs_strict_fsync()
2604 trace_cifs_fsync_err(inode->i_ino, rc); in cifs_strict_fsync()
2610 cifs_dbg(FYI, "Sync file - name: %pD datasync: 0x%x\n", in cifs_strict_fsync()
2621 tcon = tlink_tcon(smbfile->tlink); in cifs_strict_fsync()
2622 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) { in cifs_strict_fsync()
2623 server = tcon->ses->server; in cifs_strict_fsync()
2624 if (server->ops->flush == NULL) { in cifs_strict_fsync()
2625 rc = -ENOSYS; in cifs_strict_fsync()
2629 if ((OPEN_FMODE(smbfile->f_flags) & FMODE_WRITE) == 0) { in cifs_strict_fsync()
2632 rc = server->ops->flush(xid, tcon, &smbfile->fid); in cifs_strict_fsync()
2637 rc = server->ops->flush(xid, tcon, &smbfile->fid); in cifs_strict_fsync()
2649 struct cifs_tcon *tcon; in cifs_fsync() local
2651 struct cifsFileInfo *smbfile = file->private_data; in cifs_fsync()
2657 trace_cifs_fsync_err(file_inode(file)->i_ino, rc); in cifs_fsync()
2663 cifs_dbg(FYI, "Sync file - name: %pD datasync: 0x%x\n", in cifs_fsync()
2666 tcon = tlink_tcon(smbfile->tlink); in cifs_fsync()
2667 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) { in cifs_fsync()
2668 server = tcon->ses->server; in cifs_fsync()
2669 if (server->ops->flush == NULL) { in cifs_fsync()
2670 rc = -ENOSYS; in cifs_fsync()
2674 if ((OPEN_FMODE(smbfile->f_flags) & FMODE_WRITE) == 0) { in cifs_fsync()
2677 rc = server->ops->flush(xid, tcon, &smbfile->fid); in cifs_fsync()
2682 rc = server->ops->flush(xid, tcon, &smbfile->fid); in cifs_fsync()
2699 if (file->f_mode & FMODE_WRITE) in cifs_flush()
2700 rc = filemap_write_and_wait(inode->i_mapping); in cifs_flush()
2704 trace_cifs_flush_err(inode->i_ino, rc); in cifs_flush()
2722 rc = -ENOMEM; in cifs_write_allocate_pages()
2756 kref_put(&wdata->ctx->refcount, cifs_aio_ctx_release); in cifs_uncached_writedata_release()
2757 for (i = 0; i < wdata->nr_pages; i++) in cifs_uncached_writedata_release()
2758 put_page(wdata->pages[i]); in cifs_uncached_writedata_release()
2769 struct inode *inode = d_inode(wdata->cfile->dentry); in cifs_uncached_writev_complete()
2772 spin_lock(&inode->i_lock); in cifs_uncached_writev_complete()
2773 cifs_update_eof(cifsi, wdata->offset, wdata->bytes); in cifs_uncached_writev_complete()
2774 if (cifsi->server_eof > inode->i_size) in cifs_uncached_writev_complete()
2775 i_size_write(inode, cifsi->server_eof); in cifs_uncached_writev_complete()
2776 spin_unlock(&inode->i_lock); in cifs_uncached_writev_complete()
2778 complete(&wdata->done); in cifs_uncached_writev_complete()
2779 collect_uncached_write_data(wdata->ctx); in cifs_uncached_writev_complete()
2781 kref_put(&wdata->refcount, cifs_uncached_writedata_release); in cifs_uncached_writev_complete()
2794 copied = copy_page_from_iter(wdata->pages[i], 0, bytes, from); in wdata_fill_from_iovec()
2795 cur_len -= copied; in wdata_fill_from_iovec()
2800 * loop, we'll likely end up getting a zero-length in wdata_fill_from_iovec()
2806 cur_len = save_len - cur_len; in wdata_fill_from_iovec()
2812 * the address in the iovec was bogus. Return -EFAULT and let in wdata_fill_from_iovec()
2816 return -EFAULT; in wdata_fill_from_iovec()
2833 struct TCP_Server_Info *server = wdata->server; in cifs_resend_wdata()
2836 if (wdata->cfile->invalidHandle) { in cifs_resend_wdata()
2837 rc = cifs_reopen_file(wdata->cfile, false); in cifs_resend_wdata()
2838 if (rc == -EAGAIN) in cifs_resend_wdata()
2851 rc = server->ops->wait_mtu_credits(server, wdata->bytes, in cifs_resend_wdata()
2856 if (wsize < wdata->bytes) { in cifs_resend_wdata()
2860 } while (wsize < wdata->bytes); in cifs_resend_wdata()
2861 wdata->credits = credits; in cifs_resend_wdata()
2863 rc = adjust_credits(server, &wdata->credits, wdata->bytes); in cifs_resend_wdata()
2866 if (wdata->cfile->invalidHandle) in cifs_resend_wdata()
2867 rc = -EAGAIN; in cifs_resend_wdata()
2870 if (wdata->mr) { in cifs_resend_wdata()
2871 wdata->mr->need_invalidate = true; in cifs_resend_wdata()
2872 smbd_deregister_mr(wdata->mr); in cifs_resend_wdata()
2873 wdata->mr = NULL; in cifs_resend_wdata()
2876 rc = server->ops->async_writev(wdata, in cifs_resend_wdata()
2883 list_add_tail(&wdata->list, wdata_list); in cifs_resend_wdata()
2888 add_credits_and_wake_if(server, &wdata->credits, 0); in cifs_resend_wdata()
2889 } while (rc == -EAGAIN); in cifs_resend_wdata()
2892 kref_put(&wdata->refcount, cifs_uncached_writedata_release); in cifs_resend_wdata()
2914 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) in cifs_write_from_iter()
2915 pid = open_file->pid; in cifs_write_from_iter()
2917 pid = current->tgid; in cifs_write_from_iter()
2919 server = cifs_pick_channel(tlink_tcon(open_file->tlink)->ses); in cifs_write_from_iter()
2927 if (open_file->invalidHandle) { in cifs_write_from_iter()
2929 if (rc == -EAGAIN) in cifs_write_from_iter()
2935 rc = server->ops->wait_mtu_credits(server, cifs_sb->wsize, in cifs_write_from_iter()
2942 if (ctx->direct_io) { in cifs_write_from_iter()
2951 from->iov_offset, from->count); in cifs_write_from_iter()
2962 (cur_len + start + PAGE_SIZE - 1) / PAGE_SIZE; in cifs_write_from_iter()
2967 rc = -ENOMEM; in cifs_write_from_iter()
2973 wdata->page_offset = start; in cifs_write_from_iter()
2974 wdata->tailsz = in cifs_write_from_iter()
2976 cur_len - (PAGE_SIZE - start) - in cifs_write_from_iter()
2977 (nr_pages - 2) * PAGE_SIZE : in cifs_write_from_iter()
2984 rc = -ENOMEM; in cifs_write_from_iter()
2989 rc = cifs_write_allocate_pages(wdata->pages, nr_pages); in cifs_write_from_iter()
2991 kvfree(wdata->pages); in cifs_write_from_iter()
3002 put_page(wdata->pages[i]); in cifs_write_from_iter()
3003 kvfree(wdata->pages); in cifs_write_from_iter()
3013 for ( ; nr_pages > num_pages; nr_pages--) in cifs_write_from_iter()
3014 put_page(wdata->pages[nr_pages - 1]); in cifs_write_from_iter()
3016 wdata->tailsz = cur_len - ((nr_pages - 1) * PAGE_SIZE); in cifs_write_from_iter()
3019 wdata->sync_mode = WB_SYNC_ALL; in cifs_write_from_iter()
3020 wdata->nr_pages = nr_pages; in cifs_write_from_iter()
3021 wdata->offset = (__u64)offset; in cifs_write_from_iter()
3022 wdata->cfile = cifsFileInfo_get(open_file); in cifs_write_from_iter()
3023 wdata->server = server; in cifs_write_from_iter()
3024 wdata->pid = pid; in cifs_write_from_iter()
3025 wdata->bytes = cur_len; in cifs_write_from_iter()
3026 wdata->pagesz = PAGE_SIZE; in cifs_write_from_iter()
3027 wdata->credits = credits_on_stack; in cifs_write_from_iter()
3028 wdata->ctx = ctx; in cifs_write_from_iter()
3029 kref_get(&ctx->refcount); in cifs_write_from_iter()
3031 rc = adjust_credits(server, &wdata->credits, wdata->bytes); in cifs_write_from_iter()
3034 if (wdata->cfile->invalidHandle) in cifs_write_from_iter()
3035 rc = -EAGAIN; in cifs_write_from_iter()
3037 rc = server->ops->async_writev(wdata, in cifs_write_from_iter()
3042 add_credits_and_wake_if(server, &wdata->credits, 0); in cifs_write_from_iter()
3043 kref_put(&wdata->refcount, in cifs_write_from_iter()
3045 if (rc == -EAGAIN) { in cifs_write_from_iter()
3047 iov_iter_advance(from, offset - saved_offset); in cifs_write_from_iter()
3053 list_add_tail(&wdata->list, wdata_list); in cifs_write_from_iter()
3055 len -= cur_len; in cifs_write_from_iter()
3065 struct cifs_tcon *tcon; in collect_uncached_write_data() local
3067 struct dentry *dentry = ctx->cfile->dentry; in collect_uncached_write_data()
3070 tcon = tlink_tcon(ctx->cfile->tlink); in collect_uncached_write_data()
3071 cifs_sb = CIFS_SB(dentry->d_sb); in collect_uncached_write_data()
3073 mutex_lock(&ctx->aio_mutex); in collect_uncached_write_data()
3075 if (list_empty(&ctx->list)) { in collect_uncached_write_data()
3076 mutex_unlock(&ctx->aio_mutex); in collect_uncached_write_data()
3080 rc = ctx->rc; in collect_uncached_write_data()
3087 list_for_each_entry_safe(wdata, tmp, &ctx->list, list) { in collect_uncached_write_data()
3089 if (!try_wait_for_completion(&wdata->done)) { in collect_uncached_write_data()
3090 mutex_unlock(&ctx->aio_mutex); in collect_uncached_write_data()
3094 if (wdata->result) in collect_uncached_write_data()
3095 rc = wdata->result; in collect_uncached_write_data()
3097 ctx->total_len += wdata->bytes; in collect_uncached_write_data()
3100 if (rc == -EAGAIN) { in collect_uncached_write_data()
3102 struct iov_iter tmp_from = ctx->iter; in collect_uncached_write_data()
3105 list_del_init(&wdata->list); in collect_uncached_write_data()
3107 if (ctx->direct_io) in collect_uncached_write_data()
3112 wdata->offset - ctx->pos); in collect_uncached_write_data()
3114 rc = cifs_write_from_iter(wdata->offset, in collect_uncached_write_data()
3115 wdata->bytes, &tmp_from, in collect_uncached_write_data()
3116 ctx->cfile, cifs_sb, &tmp_list, in collect_uncached_write_data()
3119 kref_put(&wdata->refcount, in collect_uncached_write_data()
3123 list_splice(&tmp_list, &ctx->list); in collect_uncached_write_data()
3127 list_del_init(&wdata->list); in collect_uncached_write_data()
3128 kref_put(&wdata->refcount, cifs_uncached_writedata_release); in collect_uncached_write_data()
3131 cifs_stats_bytes_written(tcon, ctx->total_len); in collect_uncached_write_data()
3132 set_bit(CIFS_INO_INVALID_MAPPING, &CIFS_I(dentry->d_inode)->flags); in collect_uncached_write_data()
3134 ctx->rc = (rc == 0) ? ctx->total_len : rc; in collect_uncached_write_data()
3136 mutex_unlock(&ctx->aio_mutex); in collect_uncached_write_data()
3138 if (ctx->iocb && ctx->iocb->ki_complete) in collect_uncached_write_data()
3139 ctx->iocb->ki_complete(ctx->iocb, ctx->rc, 0); in collect_uncached_write_data()
3141 complete(&ctx->done); in collect_uncached_write_data()
3147 struct file *file = iocb->ki_filp; in __cifs_writev()
3150 struct cifs_tcon *tcon; in __cifs_writev() local
3159 * In this case, fall back to non-direct write function. in __cifs_writev()
3163 cifs_dbg(FYI, "use non-direct cifs_writev for kvec I/O\n"); in __cifs_writev()
3172 cfile = file->private_data; in __cifs_writev()
3173 tcon = tlink_tcon(cfile->tlink); in __cifs_writev()
3175 if (!tcon->ses->server->ops->async_writev) in __cifs_writev()
3176 return -ENOSYS; in __cifs_writev()
3180 return -ENOMEM; in __cifs_writev()
3182 ctx->cfile = cifsFileInfo_get(cfile); in __cifs_writev()
3185 ctx->iocb = iocb; in __cifs_writev()
3187 ctx->pos = iocb->ki_pos; in __cifs_writev()
3190 ctx->direct_io = true; in __cifs_writev()
3191 ctx->iter = *from; in __cifs_writev()
3192 ctx->len = len; in __cifs_writev()
3196 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_writev()
3202 mutex_lock(&ctx->aio_mutex); in __cifs_writev()
3204 rc = cifs_write_from_iter(iocb->ki_pos, ctx->len, &saved_from, in __cifs_writev()
3205 cfile, cifs_sb, &ctx->list, ctx); in __cifs_writev()
3213 if (!list_empty(&ctx->list)) in __cifs_writev()
3216 mutex_unlock(&ctx->aio_mutex); in __cifs_writev()
3219 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_writev()
3224 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_writev()
3225 return -EIOCBQUEUED; in __cifs_writev()
3228 rc = wait_for_completion_killable(&ctx->done); in __cifs_writev()
3230 mutex_lock(&ctx->aio_mutex); in __cifs_writev()
3231 ctx->rc = rc = -EINTR; in __cifs_writev()
3232 total_written = ctx->total_len; in __cifs_writev()
3233 mutex_unlock(&ctx->aio_mutex); in __cifs_writev()
3235 rc = ctx->rc; in __cifs_writev()
3236 total_written = ctx->total_len; in __cifs_writev()
3239 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_writev()
3244 iocb->ki_pos += total_written; in __cifs_writev()
3250 struct file *file = iocb->ki_filp; in cifs_direct_writev()
3252 cifs_revalidate_mapping(file->f_inode); in cifs_direct_writev()
3264 struct file *file = iocb->ki_filp; in cifs_writev()
3265 struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data; in cifs_writev()
3266 struct inode *inode = file->f_mapping->host; in cifs_writev()
3268 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server; in cifs_writev()
3276 down_read(&cinode->lock_sem); in cifs_writev()
3282 if (!cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(from), in cifs_writev()
3283 server->vals->exclusive_lock_type, 0, in cifs_writev()
3287 rc = -EACCES; in cifs_writev()
3289 up_read(&cinode->lock_sem); in cifs_writev()
3300 struct inode *inode = file_inode(iocb->ki_filp); in cifs_strict_writev()
3302 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); in cifs_strict_writev()
3304 iocb->ki_filp->private_data; in cifs_strict_writev()
3305 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); in cifs_strict_writev() local
3313 if (cap_unix(tcon->ses) && in cifs_strict_writev()
3314 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) in cifs_strict_writev()
3315 && ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) { in cifs_strict_writev()
3323 * For non-oplocked files in strict cache mode we need to write the data in cifs_strict_writev()
3324 * to the server exactly from the pos to pos+len-1 rather than flush all in cifs_strict_writev()
3326 * these pages but not on the region from pos to ppos+len-1. in cifs_strict_writev()
3340 cinode->oplock = 0; in cifs_strict_writev()
3354 rdata->pages = pages; in cifs_readdata_direct_alloc()
3355 kref_init(&rdata->refcount); in cifs_readdata_direct_alloc()
3356 INIT_LIST_HEAD(&rdata->list); in cifs_readdata_direct_alloc()
3357 init_completion(&rdata->done); in cifs_readdata_direct_alloc()
3358 INIT_WORK(&rdata->work, complete); in cifs_readdata_direct_alloc()
3386 if (rdata->mr) { in cifs_readdata_release()
3387 smbd_deregister_mr(rdata->mr); in cifs_readdata_release()
3388 rdata->mr = NULL; in cifs_readdata_release()
3391 if (rdata->cfile) in cifs_readdata_release()
3392 cifsFileInfo_put(rdata->cfile); in cifs_readdata_release()
3394 kvfree(rdata->pages); in cifs_readdata_release()
3408 rc = -ENOMEM; in cifs_read_allocate_pages()
3411 rdata->pages[i] = page; in cifs_read_allocate_pages()
3418 put_page(rdata->pages[i]); in cifs_read_allocate_pages()
3419 rdata->pages[i] = NULL; in cifs_read_allocate_pages()
3432 kref_put(&rdata->ctx->refcount, cifs_aio_ctx_release); in cifs_uncached_readdata_release()
3433 for (i = 0; i < rdata->nr_pages; i++) { in cifs_uncached_readdata_release()
3434 put_page(rdata->pages[i]); in cifs_uncached_readdata_release()
3440 * cifs_readdata_to_iov - copy data from pages in response to an iovec
3451 size_t remaining = rdata->got_bytes; in cifs_readdata_to_iov()
3454 for (i = 0; i < rdata->nr_pages; i++) { in cifs_readdata_to_iov()
3455 struct page *page = rdata->pages[i]; in cifs_readdata_to_iov()
3466 remaining -= written; in cifs_readdata_to_iov()
3470 return remaining ? -EFAULT : 0; in cifs_readdata_to_iov()
3481 complete(&rdata->done); in cifs_uncached_readv_complete()
3482 collect_uncached_read_data(rdata->ctx); in cifs_uncached_readv_complete()
3484 kref_put(&rdata->refcount, cifs_uncached_readdata_release); in cifs_uncached_readv_complete()
3494 unsigned int nr_pages = rdata->nr_pages; in uncached_fill_pages()
3495 unsigned int page_offset = rdata->page_offset; in uncached_fill_pages()
3497 rdata->got_bytes = 0; in uncached_fill_pages()
3498 rdata->tailsz = PAGE_SIZE; in uncached_fill_pages()
3500 struct page *page = rdata->pages[i]; in uncached_fill_pages()
3502 unsigned int segment_size = rdata->pagesz; in uncached_fill_pages()
3505 segment_size -= page_offset; in uncached_fill_pages()
3512 rdata->pages[i] = NULL; in uncached_fill_pages()
3513 rdata->nr_pages--; in uncached_fill_pages()
3523 rdata->tailsz = len; in uncached_fill_pages()
3524 len -= n; in uncached_fill_pages()
3530 else if (rdata->mr) in uncached_fill_pages()
3539 rdata->got_bytes += result; in uncached_fill_pages()
3542 return rdata->got_bytes > 0 && result != -ECONNABORTED ? in uncached_fill_pages()
3543 rdata->got_bytes : result; in uncached_fill_pages()
3558 return uncached_fill_pages(server, rdata, iter, iter->count); in cifs_uncached_copy_into_pages()
3570 /* XXX: should we pick a new channel here? */ in cifs_resend_rdata()
3571 server = rdata->server; in cifs_resend_rdata()
3574 if (rdata->cfile->invalidHandle) { in cifs_resend_rdata()
3575 rc = cifs_reopen_file(rdata->cfile, true); in cifs_resend_rdata()
3576 if (rc == -EAGAIN) in cifs_resend_rdata()
3588 rc = server->ops->wait_mtu_credits(server, rdata->bytes, in cifs_resend_rdata()
3594 if (rsize < rdata->bytes) { in cifs_resend_rdata()
3598 } while (rsize < rdata->bytes); in cifs_resend_rdata()
3599 rdata->credits = credits; in cifs_resend_rdata()
3601 rc = adjust_credits(server, &rdata->credits, rdata->bytes); in cifs_resend_rdata()
3603 if (rdata->cfile->invalidHandle) in cifs_resend_rdata()
3604 rc = -EAGAIN; in cifs_resend_rdata()
3607 if (rdata->mr) { in cifs_resend_rdata()
3608 rdata->mr->need_invalidate = true; in cifs_resend_rdata()
3609 smbd_deregister_mr(rdata->mr); in cifs_resend_rdata()
3610 rdata->mr = NULL; in cifs_resend_rdata()
3613 rc = server->ops->async_readv(rdata); in cifs_resend_rdata()
3620 list_add_tail(&rdata->list, rdata_list); in cifs_resend_rdata()
3625 add_credits_and_wake_if(server, &rdata->credits, 0); in cifs_resend_rdata()
3626 } while (rc == -EAGAIN); in cifs_resend_rdata()
3629 kref_put(&rdata->refcount, cifs_uncached_readdata_release); in cifs_resend_rdata()
3648 struct iov_iter direct_iov = ctx->iter; in cifs_send_async_read()
3650 server = cifs_pick_channel(tlink_tcon(open_file->tlink)->ses); in cifs_send_async_read()
3652 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) in cifs_send_async_read()
3653 pid = open_file->pid; in cifs_send_async_read()
3655 pid = current->tgid; in cifs_send_async_read()
3657 if (ctx->direct_io) in cifs_send_async_read()
3658 iov_iter_advance(&direct_iov, offset - ctx->pos); in cifs_send_async_read()
3661 if (open_file->invalidHandle) { in cifs_send_async_read()
3663 if (rc == -EAGAIN) in cifs_send_async_read()
3669 rc = server->ops->wait_mtu_credits(server, cifs_sb->rsize, in cifs_send_async_read()
3676 if (ctx->direct_io) { in cifs_send_async_read()
3701 rc = -ENOMEM; in cifs_send_async_read()
3705 npages = (cur_len + start + PAGE_SIZE-1) / PAGE_SIZE; in cifs_send_async_read()
3706 rdata->page_offset = start; in cifs_send_async_read()
3707 rdata->tailsz = npages > 1 ? in cifs_send_async_read()
3708 cur_len-(PAGE_SIZE-start)-(npages-2)*PAGE_SIZE : in cifs_send_async_read()
3719 rc = -ENOMEM; in cifs_send_async_read()
3725 kvfree(rdata->pages); in cifs_send_async_read()
3731 rdata->tailsz = PAGE_SIZE; in cifs_send_async_read()
3734 rdata->server = server; in cifs_send_async_read()
3735 rdata->cfile = cifsFileInfo_get(open_file); in cifs_send_async_read()
3736 rdata->nr_pages = npages; in cifs_send_async_read()
3737 rdata->offset = offset; in cifs_send_async_read()
3738 rdata->bytes = cur_len; in cifs_send_async_read()
3739 rdata->pid = pid; in cifs_send_async_read()
3740 rdata->pagesz = PAGE_SIZE; in cifs_send_async_read()
3741 rdata->read_into_pages = cifs_uncached_read_into_pages; in cifs_send_async_read()
3742 rdata->copy_into_pages = cifs_uncached_copy_into_pages; in cifs_send_async_read()
3743 rdata->credits = credits_on_stack; in cifs_send_async_read()
3744 rdata->ctx = ctx; in cifs_send_async_read()
3745 kref_get(&ctx->refcount); in cifs_send_async_read()
3747 rc = adjust_credits(server, &rdata->credits, rdata->bytes); in cifs_send_async_read()
3750 if (rdata->cfile->invalidHandle) in cifs_send_async_read()
3751 rc = -EAGAIN; in cifs_send_async_read()
3753 rc = server->ops->async_readv(rdata); in cifs_send_async_read()
3757 add_credits_and_wake_if(server, &rdata->credits, 0); in cifs_send_async_read()
3758 kref_put(&rdata->refcount, in cifs_send_async_read()
3760 if (rc == -EAGAIN) { in cifs_send_async_read()
3767 list_add_tail(&rdata->list, rdata_list); in cifs_send_async_read()
3769 len -= cur_len; in cifs_send_async_read()
3779 struct iov_iter *to = &ctx->iter; in collect_uncached_read_data()
3783 cifs_sb = CIFS_SB(ctx->cfile->dentry->d_sb); in collect_uncached_read_data()
3785 mutex_lock(&ctx->aio_mutex); in collect_uncached_read_data()
3787 if (list_empty(&ctx->list)) { in collect_uncached_read_data()
3788 mutex_unlock(&ctx->aio_mutex); in collect_uncached_read_data()
3792 rc = ctx->rc; in collect_uncached_read_data()
3795 list_for_each_entry_safe(rdata, tmp, &ctx->list, list) { in collect_uncached_read_data()
3797 if (!try_wait_for_completion(&rdata->done)) { in collect_uncached_read_data()
3798 mutex_unlock(&ctx->aio_mutex); in collect_uncached_read_data()
3802 if (rdata->result == -EAGAIN) { in collect_uncached_read_data()
3805 unsigned int got_bytes = rdata->got_bytes; in collect_uncached_read_data()
3807 list_del_init(&rdata->list); in collect_uncached_read_data()
3812 * happened -- fill the buffer and continue in collect_uncached_read_data()
3815 if (got_bytes && got_bytes < rdata->bytes) { in collect_uncached_read_data()
3817 if (!ctx->direct_io) in collect_uncached_read_data()
3820 kref_put(&rdata->refcount, in collect_uncached_read_data()
3826 if (ctx->direct_io) { in collect_uncached_read_data()
3828 * Re-use rdata as this is a in collect_uncached_read_data()
3836 rdata->offset + got_bytes, in collect_uncached_read_data()
3837 rdata->bytes - got_bytes, in collect_uncached_read_data()
3838 rdata->cfile, cifs_sb, in collect_uncached_read_data()
3841 kref_put(&rdata->refcount, in collect_uncached_read_data()
3845 list_splice(&tmp_list, &ctx->list); in collect_uncached_read_data()
3848 } else if (rdata->result) in collect_uncached_read_data()
3849 rc = rdata->result; in collect_uncached_read_data()
3850 else if (!ctx->direct_io) in collect_uncached_read_data()
3853 /* if there was a short read -- discard anything left */ in collect_uncached_read_data()
3854 if (rdata->got_bytes && rdata->got_bytes < rdata->bytes) in collect_uncached_read_data()
3855 rc = -ENODATA; in collect_uncached_read_data()
3857 ctx->total_len += rdata->got_bytes; in collect_uncached_read_data()
3859 list_del_init(&rdata->list); in collect_uncached_read_data()
3860 kref_put(&rdata->refcount, cifs_uncached_readdata_release); in collect_uncached_read_data()
3863 if (!ctx->direct_io) in collect_uncached_read_data()
3864 ctx->total_len = ctx->len - iov_iter_count(to); in collect_uncached_read_data()
3867 if (rc == -ENODATA) in collect_uncached_read_data()
3870 ctx->rc = (rc == 0) ? (ssize_t)ctx->total_len : rc; in collect_uncached_read_data()
3872 mutex_unlock(&ctx->aio_mutex); in collect_uncached_read_data()
3874 if (ctx->iocb && ctx->iocb->ki_complete) in collect_uncached_read_data()
3875 ctx->iocb->ki_complete(ctx->iocb, ctx->rc, 0); in collect_uncached_read_data()
3877 complete(&ctx->done); in collect_uncached_read_data()
3884 struct file *file = iocb->ki_filp; in __cifs_readv()
3887 struct cifs_tcon *tcon; in __cifs_readv() local
3889 loff_t offset = iocb->ki_pos; in __cifs_readv()
3898 cifs_dbg(FYI, "use non-direct cifs_user_readv for kvec I/O\n"); in __cifs_readv()
3907 cfile = file->private_data; in __cifs_readv()
3908 tcon = tlink_tcon(cfile->tlink); in __cifs_readv()
3910 if (!tcon->ses->server->ops->async_readv) in __cifs_readv()
3911 return -ENOSYS; in __cifs_readv()
3913 if ((file->f_flags & O_ACCMODE) == O_WRONLY) in __cifs_readv()
3918 return -ENOMEM; in __cifs_readv()
3920 ctx->cfile = cifsFileInfo_get(cfile); in __cifs_readv()
3923 ctx->iocb = iocb; in __cifs_readv()
3926 ctx->should_dirty = true; in __cifs_readv()
3929 ctx->pos = offset; in __cifs_readv()
3930 ctx->direct_io = true; in __cifs_readv()
3931 ctx->iter = *to; in __cifs_readv()
3932 ctx->len = len; in __cifs_readv()
3936 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_readv()
3939 len = ctx->len; in __cifs_readv()
3943 rc = filemap_write_and_wait_range(file->f_inode->i_mapping, in __cifs_readv()
3944 offset, offset + len - 1); in __cifs_readv()
3946 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_readv()
3947 return -EAGAIN; in __cifs_readv()
3952 mutex_lock(&ctx->aio_mutex); in __cifs_readv()
3954 rc = cifs_send_async_read(offset, len, cfile, cifs_sb, &ctx->list, ctx); in __cifs_readv()
3957 if (!list_empty(&ctx->list)) in __cifs_readv()
3960 mutex_unlock(&ctx->aio_mutex); in __cifs_readv()
3963 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_readv()
3968 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_readv()
3969 return -EIOCBQUEUED; in __cifs_readv()
3972 rc = wait_for_completion_killable(&ctx->done); in __cifs_readv()
3974 mutex_lock(&ctx->aio_mutex); in __cifs_readv()
3975 ctx->rc = rc = -EINTR; in __cifs_readv()
3976 total_read = ctx->total_len; in __cifs_readv()
3977 mutex_unlock(&ctx->aio_mutex); in __cifs_readv()
3979 rc = ctx->rc; in __cifs_readv()
3980 total_read = ctx->total_len; in __cifs_readv()
3983 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_readv()
3986 iocb->ki_pos += total_read; in __cifs_readv()
4005 struct inode *inode = file_inode(iocb->ki_filp); in cifs_strict_readv()
4007 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); in cifs_strict_readv()
4009 iocb->ki_filp->private_data; in cifs_strict_readv()
4010 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); in cifs_strict_readv() local
4011 int rc = -EACCES; in cifs_strict_readv()
4016 * change - so we can't make a decision about inode invalidating. in cifs_strict_readv()
4019 * pos+len-1. in cifs_strict_readv()
4024 if (cap_unix(tcon->ses) && in cifs_strict_readv()
4025 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && in cifs_strict_readv()
4026 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) in cifs_strict_readv()
4033 down_read(&cinode->lock_sem); in cifs_strict_readv()
4034 if (!cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(to), in cifs_strict_readv()
4035 tcon->ses->server->vals->shared_lock_type, in cifs_strict_readv()
4038 up_read(&cinode->lock_sem); in cifs_strict_readv()
4045 int rc = -EACCES; in cifs_read()
4051 struct cifs_tcon *tcon; in cifs_read() local
4064 rsize = min_t(unsigned int, cifs_sb->rsize, CIFSMaxBufSize); in cifs_read()
4066 if (file->private_data == NULL) { in cifs_read()
4067 rc = -EBADF; in cifs_read()
4071 open_file = file->private_data; in cifs_read()
4072 tcon = tlink_tcon(open_file->tlink); in cifs_read()
4073 server = cifs_pick_channel(tcon->ses); in cifs_read()
4075 if (!server->ops->sync_read) { in cifs_read()
4077 return -ENOSYS; in cifs_read()
4080 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) in cifs_read()
4081 pid = open_file->pid; in cifs_read()
4083 pid = current->tgid; in cifs_read()
4085 if ((file->f_flags & O_ACCMODE) == O_WRONLY) in cifs_read()
4091 current_read_size = min_t(uint, read_size - total_read, in cifs_read()
4098 if (!(tcon->ses->capabilities & in cifs_read()
4099 tcon->ses->server->vals->cap_large_files)) { in cifs_read()
4103 if (open_file->invalidHandle) { in cifs_read()
4109 io_parms.tcon = tcon; in cifs_read()
4113 rc = server->ops->sync_read(xid, &open_file->fid, &io_parms, in cifs_read()
4116 } while (rc == -EAGAIN); in cifs_read()
4126 cifs_stats_bytes_read(tcon, total_read); in cifs_read()
4141 struct page *page = vmf->page; in cifs_page_mkwrite()
4165 vma->vm_ops = &cifs_file_vm_ops; in cifs_file_strict_mmap()
4184 vma->vm_ops = &cifs_file_vm_ops; in cifs_file_mmap()
4197 got_bytes = rdata->got_bytes; in cifs_readv_complete()
4198 for (i = 0; i < rdata->nr_pages; i++) { in cifs_readv_complete()
4199 struct page *page = rdata->pages[i]; in cifs_readv_complete()
4203 if (rdata->result == 0 || in cifs_readv_complete()
4204 (rdata->result == -EAGAIN && got_bytes)) { in cifs_readv_complete()
4211 if (rdata->result == 0 || in cifs_readv_complete()
4212 (rdata->result == -EAGAIN && got_bytes)) in cifs_readv_complete()
4213 cifs_readpage_to_fscache(rdata->mapping->host, page); in cifs_readv_complete()
4215 got_bytes -= min_t(unsigned int, PAGE_SIZE, got_bytes); in cifs_readv_complete()
4218 rdata->pages[i] = NULL; in cifs_readv_complete()
4220 kref_put(&rdata->refcount, cifs_readdata_release); in cifs_readv_complete()
4232 unsigned int nr_pages = rdata->nr_pages; in readpages_fill_pages()
4233 unsigned int page_offset = rdata->page_offset; in readpages_fill_pages()
4236 eof = CIFS_I(rdata->mapping->host)->server_eof; in readpages_fill_pages()
4237 eof_index = eof ? (eof - 1) >> PAGE_SHIFT : 0; in readpages_fill_pages()
4240 rdata->got_bytes = 0; in readpages_fill_pages()
4241 rdata->tailsz = PAGE_SIZE; in readpages_fill_pages()
4243 struct page *page = rdata->pages[i]; in readpages_fill_pages()
4244 unsigned int to_read = rdata->pagesz; in readpages_fill_pages()
4248 to_read -= page_offset; in readpages_fill_pages()
4255 len -= to_read; in readpages_fill_pages()
4258 zero_user(page, len + page_offset, to_read - len); in readpages_fill_pages()
4259 n = rdata->tailsz = len; in readpages_fill_pages()
4261 } else if (page->index > eof_index) { in readpages_fill_pages()
4276 rdata->pages[i] = NULL; in readpages_fill_pages()
4277 rdata->nr_pages--; in readpages_fill_pages()
4284 rdata->pages[i] = NULL; in readpages_fill_pages()
4285 rdata->nr_pages--; in readpages_fill_pages()
4293 else if (rdata->mr) in readpages_fill_pages()
4302 rdata->got_bytes += result; in readpages_fill_pages()
4305 return rdata->got_bytes > 0 && result != -ECONNABORTED ? in readpages_fill_pages()
4306 rdata->got_bytes : result; in readpages_fill_pages()
4321 return readpages_fill_pages(server, rdata, iter, iter->count); in cifs_readpages_copy_into_pages()
4345 page->index, gfp); in readpages_get_pages()
4354 *offset = (loff_t)page->index << PAGE_SHIFT; in readpages_get_pages()
4357 list_move_tail(&page->lru, tmplist); in readpages_get_pages()
4360 expected_index = page->index + 1; in readpages_get_pages()
4363 if (page->index != expected_index) in readpages_get_pages()
4371 rc = add_to_page_cache_locked(page, mapping, page->index, gfp); in readpages_get_pages()
4376 list_move_tail(&page->lru, tmplist); in readpages_get_pages()
4390 struct cifsFileInfo *open_file = file->private_data; in cifs_readpages()
4398 * Reads as many pages as possible from fscache. Returns -ENOBUFS in cifs_readpages()
4404 rc = cifs_readpages_from_fscache(mapping->host, mapping, page_list, in cifs_readpages()
4411 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) in cifs_readpages()
4412 pid = open_file->pid; in cifs_readpages()
4414 pid = current->tgid; in cifs_readpages()
4417 server = cifs_pick_channel(tlink_tcon(open_file->tlink)->ses); in cifs_readpages()
4431 * the rdata->pages, then we want them in increasing order. in cifs_readpages()
4441 if (open_file->invalidHandle) { in cifs_readpages()
4443 if (rc == -EAGAIN) in cifs_readpages()
4449 rc = server->ops->wait_mtu_credits(server, cifs_sb->rsize, in cifs_readpages()
4478 list_del(&page->lru); in cifs_readpages()
4483 rc = -ENOMEM; in cifs_readpages()
4488 rdata->cfile = cifsFileInfo_get(open_file); in cifs_readpages()
4489 rdata->server = server; in cifs_readpages()
4490 rdata->mapping = mapping; in cifs_readpages()
4491 rdata->offset = offset; in cifs_readpages()
4492 rdata->bytes = bytes; in cifs_readpages()
4493 rdata->pid = pid; in cifs_readpages()
4494 rdata->pagesz = PAGE_SIZE; in cifs_readpages()
4495 rdata->tailsz = PAGE_SIZE; in cifs_readpages()
4496 rdata->read_into_pages = cifs_readpages_read_into_pages; in cifs_readpages()
4497 rdata->copy_into_pages = cifs_readpages_copy_into_pages; in cifs_readpages()
4498 rdata->credits = credits_on_stack; in cifs_readpages()
4501 list_del(&page->lru); in cifs_readpages()
4502 rdata->pages[rdata->nr_pages++] = page; in cifs_readpages()
4505 rc = adjust_credits(server, &rdata->credits, rdata->bytes); in cifs_readpages()
4508 if (rdata->cfile->invalidHandle) in cifs_readpages()
4509 rc = -EAGAIN; in cifs_readpages()
4511 rc = server->ops->async_readv(rdata); in cifs_readpages()
4515 add_credits_and_wake_if(server, &rdata->credits, 0); in cifs_readpages()
4516 for (i = 0; i < rdata->nr_pages; i++) { in cifs_readpages()
4517 page = rdata->pages[i]; in cifs_readpages()
4523 kref_put(&rdata->refcount, cifs_readdata_release); in cifs_readpages()
4527 kref_put(&rdata->refcount, cifs_readdata_release); in cifs_readpages()
4534 cifs_fscache_readpages_cancel(mapping->host, page_list); in cifs_readpages()
4564 file_inode(file)->i_atime = current_time(file_inode(file)); in cifs_readpage_worker()
4565 if (timespec64_compare(&(file_inode(file)->i_atime), &(file_inode(file)->i_mtime))) in cifs_readpage_worker()
4566 file_inode(file)->i_atime = file_inode(file)->i_mtime; in cifs_readpage_worker()
4568 file_inode(file)->i_atime = current_time(file_inode(file)); in cifs_readpage_worker()
4571 memset(read_data + rc, 0, PAGE_SIZE - rc); in cifs_readpage_worker()
4592 int rc = -EACCES; in cifs_readpage()
4597 if (file->private_data == NULL) { in cifs_readpage()
4598 rc = -EBADF; in cifs_readpage()
4616 spin_lock(&cifs_inode->open_file_lock); in is_inode_writable()
4617 list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { in is_inode_writable()
4618 if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) { in is_inode_writable()
4619 spin_unlock(&cifs_inode->open_file_lock); in is_inode_writable()
4623 spin_unlock(&cifs_inode->open_file_lock); in is_inode_writable()
4628 open for write - to avoid races with writepage extending
4629 the file - in the future we could consider allowing
4642 cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb); in is_size_safe_to_change()
4643 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { in is_size_safe_to_change()
4649 if (i_size_read(&cifsInode->vfs_inode) < end_of_file) in is_size_safe_to_change()
4663 loff_t offset = pos & (PAGE_SIZE - 1); in cifs_write_begin()
4674 rc = -ENOMEM; in cifs_write_begin()
4695 if (CIFS_CACHE_READ(CIFS_I(mapping->host))) { in cifs_write_begin()
4696 i_size = i_size_read(mapping->host); in cifs_write_begin()
4713 if ((file->f_flags & O_ACCMODE) != O_WRONLY && !oncethru) { in cifs_write_begin()
4724 /* we could try using another file handle if there is one - in cifs_write_begin()
4745 struct cifsInodeInfo *cifsi = CIFS_I(page->mapping->host); in cifs_invalidate_page()
4748 cifs_fscache_invalidate_page(page, &cifsi->vfs_inode); in cifs_invalidate_page()
4755 loff_t range_end = range_start + (loff_t)(PAGE_SIZE - 1); in cifs_launder_page()
4768 cifs_fscache_invalidate_page(page, page->mapping->host); in cifs_launder_page()
4776 struct inode *inode = d_inode(cfile->dentry); in cifs_oplock_break()
4778 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); in cifs_oplock_break() local
4779 struct TCP_Server_Info *server = tcon->ses->server; in cifs_oplock_break()
4783 wait_on_bit(&cinode->flags, CIFS_INODE_PENDING_WRITERS, in cifs_oplock_break()
4786 server->ops->downgrade_oplock(server, cinode, cfile->oplock_level, in cifs_oplock_break()
4787 cfile->oplock_epoch, &purge_cache); in cifs_oplock_break()
4793 cinode->oplock = 0; in cifs_oplock_break()
4796 if (inode && S_ISREG(inode->i_mode)) { in cifs_oplock_break()
4801 rc = filemap_fdatawrite(inode->i_mapping); in cifs_oplock_break()
4803 rc = filemap_fdatawait(inode->i_mapping); in cifs_oplock_break()
4804 mapping_set_error(inode->i_mapping, rc); in cifs_oplock_break()
4823 if (!cfile->oplock_break_cancelled) { in cifs_oplock_break()
4824 rc = tcon->ses->server->ops->oplock_response(tcon, &cfile->fid, in cifs_oplock_break()
4836 * In the non-cached mode (mount with cache=none), we shunt off direct read and write requests
4848 return -EINVAL; in cifs_direct_io()
4854 struct cifsFileInfo *cfile = swap_file->private_data; in cifs_swap_activate()
4855 struct inode *inode = swap_file->f_mapping->host; in cifs_swap_activate()
4861 spin_lock(&inode->i_lock); in cifs_swap_activate()
4862 blocks = inode->i_blocks; in cifs_swap_activate()
4863 isize = inode->i_size; in cifs_swap_activate()
4864 spin_unlock(&inode->i_lock); in cifs_swap_activate()
4867 return -EINVAL; in cifs_swap_activate()
4869 *span = sis->pages; in cifs_swap_activate()
4882 cfile->swapfile = true; in cifs_swap_activate()
4894 struct cifsFileInfo *cfile = file->private_data; in cifs_swap_deactivate()
4901 cfile->swapfile = false; in cifs_swap_deactivate()