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
1738 rc = -EACCES; in cifs_flock()
1741 if (!(fl->fl_flags & FL_FLOCK)) in cifs_flock()
1742 return -ENOLCK; in cifs_flock()
1744 cfile = (struct cifsFileInfo *)file->private_data; in cifs_flock()
1745 tcon = tlink_tcon(cfile->tlink); in cifs_flock()
1748 tcon->ses->server); in cifs_flock()
1751 if (cap_unix(tcon->ses) && in cifs_flock()
1752 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && in cifs_flock()
1753 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) in cifs_flock()
1762 return -EOPNOTSUPP; in cifs_flock()
1780 struct cifs_tcon *tcon; in cifs_lock() local
1784 rc = -EACCES; in cifs_lock()
1788 cmd, flock->fl_flags, flock->fl_type, in cifs_lock()
1789 flock->fl_start, flock->fl_end); in cifs_lock()
1791 cfile = (struct cifsFileInfo *)file->private_data; in cifs_lock()
1792 tcon = tlink_tcon(cfile->tlink); in cifs_lock()
1795 tcon->ses->server); in cifs_lock()
1798 if (cap_unix(tcon->ses) && in cifs_lock()
1799 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && in cifs_lock()
1800 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) in cifs_lock()
1818 return -EOPNOTSUPP; in cifs_lock()
1829 * the inode->i_lock held
1837 if (end_of_write > cifsi->server_eof) in cifs_update_eof()
1838 cifsi->server_eof = end_of_write; in cifs_update_eof()
1848 struct cifs_tcon *tcon; in cifs_write() local
1851 struct dentry *dentry = open_file->dentry; in cifs_write()
1858 tcon = tlink_tcon(open_file->tlink); in cifs_write()
1859 server = tcon->ses->server; in cifs_write()
1861 if (!server->ops->sync_write) in cifs_write()
1862 return -ENOSYS; in cifs_write()
1868 rc = -EAGAIN; in cifs_write()
1869 while (rc == -EAGAIN) { in cifs_write()
1873 if (open_file->invalidHandle) { in cifs_write()
1883 len = min(server->ops->wp_retry_size(d_inode(dentry)), in cifs_write()
1884 (unsigned int)write_size - total_written); in cifs_write()
1889 io_parms.tcon = tcon; in cifs_write()
1892 rc = server->ops->sync_write(xid, &open_file->fid, in cifs_write()
1903 spin_lock(&d_inode(dentry)->i_lock); in cifs_write()
1905 spin_unlock(&d_inode(dentry)->i_lock); in cifs_write()
1910 cifs_stats_bytes_written(tcon, total_written); in cifs_write()
1913 spin_lock(&d_inode(dentry)->i_lock); in cifs_write()
1914 if (*offset > d_inode(dentry)->i_size) in cifs_write()
1916 spin_unlock(&d_inode(dentry)->i_lock); in cifs_write()
1927 struct cifs_sb_info *cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb); in find_readable_file()
1930 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)) in find_readable_file()
1933 spin_lock(&cifs_inode->open_file_lock); in find_readable_file()
1934 /* we could simply get the first_list_entry since write-only entries in find_readable_file()
1937 list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { in find_readable_file()
1938 if (fsuid_only && !uid_eq(open_file->uid, current_fsuid())) in find_readable_file()
1940 if (OPEN_FMODE(open_file->f_flags) & FMODE_READ) { in find_readable_file()
1941 if (!open_file->invalidHandle) { in find_readable_file()
1945 spin_unlock(&cifs_inode->open_file_lock); in find_readable_file()
1953 spin_unlock(&cifs_inode->open_file_lock); in find_readable_file()
1957 /* Return -EBADF if no handle is found and general rc otherwise */
1965 int rc = -EBADF; in cifs_get_writable_file()
1972 * Having a null inode here (because mapping->host was set to zero by in cifs_get_writable_file()
1983 cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb); in cifs_get_writable_file()
1986 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)) in cifs_get_writable_file()
1989 spin_lock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
1992 spin_unlock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
1995 list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { in cifs_get_writable_file()
1996 if (!any_available && open_file->pid != current->tgid) in cifs_get_writable_file()
1998 if (fsuid_only && !uid_eq(open_file->uid, current_fsuid())) in cifs_get_writable_file()
2000 if (with_delete && !(open_file->fid.access & DELETE)) in cifs_get_writable_file()
2002 if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) { in cifs_get_writable_file()
2003 if (!open_file->invalidHandle) { in cifs_get_writable_file()
2006 spin_unlock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
2026 spin_unlock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
2035 spin_lock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
2036 list_move_tail(&inv_file->flist, &cifs_inode->openFileList); in cifs_get_writable_file()
2037 spin_unlock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
2041 spin_lock(&cifs_inode->open_file_lock); in cifs_get_writable_file()
2062 cifs_get_writable_path(struct cifs_tcon *tcon, const char *name, in cifs_get_writable_path() argument
2073 spin_lock(&tcon->open_file_lock); in cifs_get_writable_path()
2074 list_for_each(tmp, &tcon->openFileList) { in cifs_get_writable_path()
2077 full_path = build_path_from_dentry(cfile->dentry); in cifs_get_writable_path()
2079 spin_unlock(&tcon->open_file_lock); in cifs_get_writable_path()
2080 return -ENOMEM; in cifs_get_writable_path()
2088 cinode = CIFS_I(d_inode(cfile->dentry)); in cifs_get_writable_path()
2089 spin_unlock(&tcon->open_file_lock); in cifs_get_writable_path()
2093 spin_unlock(&tcon->open_file_lock); in cifs_get_writable_path()
2094 return -ENOENT; in cifs_get_writable_path()
2098 cifs_get_readable_path(struct cifs_tcon *tcon, const char *name, in cifs_get_readable_path() argument
2108 spin_lock(&tcon->open_file_lock); in cifs_get_readable_path()
2109 list_for_each(tmp, &tcon->openFileList) { in cifs_get_readable_path()
2112 full_path = build_path_from_dentry(cfile->dentry); in cifs_get_readable_path()
2114 spin_unlock(&tcon->open_file_lock); in cifs_get_readable_path()
2115 return -ENOMEM; in cifs_get_readable_path()
2123 cinode = CIFS_I(d_inode(cfile->dentry)); in cifs_get_readable_path()
2124 spin_unlock(&tcon->open_file_lock); in cifs_get_readable_path()
2126 return *ret_file ? 0 : -ENOENT; in cifs_get_readable_path()
2129 spin_unlock(&tcon->open_file_lock); in cifs_get_readable_path()
2130 return -ENOENT; in cifs_get_readable_path()
2135 struct address_space *mapping = page->mapping; in cifs_partialpagewrite()
2136 loff_t offset = (loff_t)page->index << PAGE_SHIFT; in cifs_partialpagewrite()
2138 int rc = -EFAULT; in cifs_partialpagewrite()
2143 if (!mapping || !mapping->host) in cifs_partialpagewrite()
2144 return -EFAULT; in cifs_partialpagewrite()
2146 inode = page->mapping->host; in cifs_partialpagewrite()
2154 return -EIO; in cifs_partialpagewrite()
2158 if (offset > mapping->host->i_size) { in cifs_partialpagewrite()
2164 if (mapping->host->i_size - offset < (loff_t)to) in cifs_partialpagewrite()
2165 to = (unsigned)(mapping->host->i_size - offset); in cifs_partialpagewrite()
2167 rc = cifs_get_writable_file(CIFS_I(mapping->host), FIND_WR_ANY, in cifs_partialpagewrite()
2170 bytes_written = cifs_write(open_file, open_file->pid, in cifs_partialpagewrite()
2171 write_data, to - from, &offset); in cifs_partialpagewrite()
2174 inode->i_atime = inode->i_mtime = current_time(inode); in cifs_partialpagewrite()
2180 rc = -EFAULT; in cifs_partialpagewrite()
2184 rc = -EIO; in cifs_partialpagewrite()
2204 PAGECACHE_TAG_DIRTY, tofind, wdata->pages); in wdata_alloc_and_fillpages()
2218 page = wdata->pages[i]; in wdata_prepare_pages()
2222 * (changing page->mapping to NULL), or even swizzled in wdata_prepare_pages()
2231 if (unlikely(page->mapping != mapping)) { in wdata_prepare_pages()
2236 if (!wbc->range_cyclic && page->index > end) { in wdata_prepare_pages()
2242 if (*next && (page->index != *next)) { in wdata_prepare_pages()
2248 if (wbc->sync_mode != WB_SYNC_NONE) in wdata_prepare_pages()
2262 if (page_offset(page) >= i_size_read(mapping->host)) { in wdata_prepare_pages()
2269 wdata->pages[i] = page; in wdata_prepare_pages()
2270 *next = page->index + 1; in wdata_prepare_pages()
2276 *index = wdata->pages[0]->index + 1; in wdata_prepare_pages()
2280 put_page(wdata->pages[i]); in wdata_prepare_pages()
2281 wdata->pages[i] = NULL; in wdata_prepare_pages()
2293 wdata->sync_mode = wbc->sync_mode; in wdata_send_pages()
2294 wdata->nr_pages = nr_pages; in wdata_send_pages()
2295 wdata->offset = page_offset(wdata->pages[0]); in wdata_send_pages()
2296 wdata->pagesz = PAGE_SIZE; in wdata_send_pages()
2297 wdata->tailsz = min(i_size_read(mapping->host) - in wdata_send_pages()
2298 page_offset(wdata->pages[nr_pages - 1]), in wdata_send_pages()
2300 wdata->bytes = ((nr_pages - 1) * PAGE_SIZE) + wdata->tailsz; in wdata_send_pages()
2301 wdata->pid = wdata->cfile->pid; in wdata_send_pages()
2303 rc = adjust_credits(wdata->server, &wdata->credits, wdata->bytes); in wdata_send_pages()
2307 if (wdata->cfile->invalidHandle) in wdata_send_pages()
2308 rc = -EAGAIN; in wdata_send_pages()
2310 rc = wdata->server->ops->async_writev(wdata, in wdata_send_pages()
2319 struct inode *inode = mapping->host; in cifs_writepages()
2320 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); in cifs_writepages()
2334 if (cifs_sb->wsize < PAGE_SIZE) in cifs_writepages()
2338 if (wbc->range_cyclic) { in cifs_writepages()
2339 index = mapping->writeback_index; /* Start from prev offset */ in cifs_writepages()
2340 end = -1; in cifs_writepages()
2342 index = wbc->range_start >> PAGE_SHIFT; in cifs_writepages()
2343 end = wbc->range_end >> PAGE_SHIFT; in cifs_writepages()
2344 if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) in cifs_writepages()
2348 server = cifs_pick_channel(cifs_sb_master_tcon(cifs_sb)->ses); in cifs_writepages()
2367 rc = server->ops->wait_mtu_credits(server, cifs_sb->wsize, in cifs_writepages()
2374 tofind = min((wsize / PAGE_SIZE) - 1, end - index) + 1; in cifs_writepages()
2379 rc = -ENOMEM; in cifs_writepages()
2386 kref_put(&wdata->refcount, cifs_writedata_release); in cifs_writepages()
2396 kref_put(&wdata->refcount, cifs_writedata_release); in cifs_writepages()
2401 wdata->credits = credits_on_stack; in cifs_writepages()
2402 wdata->cfile = cfile; in cifs_writepages()
2403 wdata->server = server; in cifs_writepages()
2406 if (!wdata->cfile) { in cifs_writepages()
2412 rc = -EBADF; in cifs_writepages()
2417 unlock_page(wdata->pages[i]); in cifs_writepages()
2419 /* send failure -- clean up the mess */ in cifs_writepages()
2421 add_credits_and_wake_if(server, &wdata->credits, 0); in cifs_writepages()
2425 wdata->pages[i]); in cifs_writepages()
2427 SetPageError(wdata->pages[i]); in cifs_writepages()
2428 end_page_writeback(wdata->pages[i]); in cifs_writepages()
2429 put_page(wdata->pages[i]); in cifs_writepages()
2434 kref_put(&wdata->refcount, cifs_writedata_release); in cifs_writepages()
2436 if (wbc->sync_mode == WB_SYNC_ALL && rc == -EAGAIN) { in cifs_writepages()
2450 wbc->nr_to_write -= nr_pages; in cifs_writepages()
2451 if (wbc->nr_to_write <= 0) in cifs_writepages()
2470 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) in cifs_writepages()
2471 mapping->writeback_index = index; in cifs_writepages()
2489 cifs_dbg(FYI, "ppw - page not up to date\n"); in cifs_writepage_locked()
2495 * or re-dirty the page with "redirty_page_for_writepage()" in in cifs_writepage_locked()
2498 * Just unlocking the page will cause the radix tree tag-bits in cifs_writepage_locked()
2505 if (wbc->sync_mode == WB_SYNC_ALL && rc == -EAGAIN) in cifs_writepage_locked()
2510 mapping_set_error(page->mapping, rc); in cifs_writepage_locked()
2532 struct inode *inode = mapping->host; in cifs_write_end()
2533 struct cifsFileInfo *cfile = file->private_data; in cifs_write_end()
2534 struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb); in cifs_write_end()
2537 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) in cifs_write_end()
2538 pid = cfile->pid; in cifs_write_end()
2540 pid = current->tgid; in cifs_write_end()
2554 unsigned offset = pos & (PAGE_SIZE - 1); in cifs_write_end()
2576 spin_lock(&inode->i_lock); in cifs_write_end()
2577 if (pos > inode->i_size) in cifs_write_end()
2579 spin_unlock(&inode->i_lock); in cifs_write_end()
2593 struct cifs_tcon *tcon; in cifs_strict_fsync() local
2595 struct cifsFileInfo *smbfile = file->private_data; in cifs_strict_fsync()
2597 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); in cifs_strict_fsync()
2601 trace_cifs_fsync_err(inode->i_ino, rc); in cifs_strict_fsync()
2607 cifs_dbg(FYI, "Sync file - name: %pD datasync: 0x%x\n", in cifs_strict_fsync()
2618 tcon = tlink_tcon(smbfile->tlink); in cifs_strict_fsync()
2619 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) { in cifs_strict_fsync()
2620 server = tcon->ses->server; in cifs_strict_fsync()
2621 if (server->ops->flush == NULL) { in cifs_strict_fsync()
2622 rc = -ENOSYS; in cifs_strict_fsync()
2626 if ((OPEN_FMODE(smbfile->f_flags) & FMODE_WRITE) == 0) { in cifs_strict_fsync()
2629 rc = server->ops->flush(xid, tcon, &smbfile->fid); in cifs_strict_fsync()
2634 rc = server->ops->flush(xid, tcon, &smbfile->fid); in cifs_strict_fsync()
2646 struct cifs_tcon *tcon; in cifs_fsync() local
2648 struct cifsFileInfo *smbfile = file->private_data; in cifs_fsync()
2654 trace_cifs_fsync_err(file_inode(file)->i_ino, rc); in cifs_fsync()
2660 cifs_dbg(FYI, "Sync file - name: %pD datasync: 0x%x\n", in cifs_fsync()
2663 tcon = tlink_tcon(smbfile->tlink); in cifs_fsync()
2664 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) { in cifs_fsync()
2665 server = tcon->ses->server; in cifs_fsync()
2666 if (server->ops->flush == NULL) { in cifs_fsync()
2667 rc = -ENOSYS; in cifs_fsync()
2671 if ((OPEN_FMODE(smbfile->f_flags) & FMODE_WRITE) == 0) { in cifs_fsync()
2674 rc = server->ops->flush(xid, tcon, &smbfile->fid); in cifs_fsync()
2679 rc = server->ops->flush(xid, tcon, &smbfile->fid); in cifs_fsync()
2696 if (file->f_mode & FMODE_WRITE) in cifs_flush()
2697 rc = filemap_write_and_wait(inode->i_mapping); in cifs_flush()
2701 trace_cifs_flush_err(inode->i_ino, rc); in cifs_flush()
2719 rc = -ENOMEM; in cifs_write_allocate_pages()
2753 kref_put(&wdata->ctx->refcount, cifs_aio_ctx_release); in cifs_uncached_writedata_release()
2754 for (i = 0; i < wdata->nr_pages; i++) in cifs_uncached_writedata_release()
2755 put_page(wdata->pages[i]); in cifs_uncached_writedata_release()
2766 struct inode *inode = d_inode(wdata->cfile->dentry); in cifs_uncached_writev_complete()
2769 spin_lock(&inode->i_lock); in cifs_uncached_writev_complete()
2770 cifs_update_eof(cifsi, wdata->offset, wdata->bytes); in cifs_uncached_writev_complete()
2771 if (cifsi->server_eof > inode->i_size) in cifs_uncached_writev_complete()
2772 i_size_write(inode, cifsi->server_eof); in cifs_uncached_writev_complete()
2773 spin_unlock(&inode->i_lock); in cifs_uncached_writev_complete()
2775 complete(&wdata->done); in cifs_uncached_writev_complete()
2776 collect_uncached_write_data(wdata->ctx); in cifs_uncached_writev_complete()
2778 kref_put(&wdata->refcount, cifs_uncached_writedata_release); in cifs_uncached_writev_complete()
2791 copied = copy_page_from_iter(wdata->pages[i], 0, bytes, from); in wdata_fill_from_iovec()
2792 cur_len -= copied; in wdata_fill_from_iovec()
2797 * loop, we'll likely end up getting a zero-length in wdata_fill_from_iovec()
2803 cur_len = save_len - cur_len; in wdata_fill_from_iovec()
2809 * the address in the iovec was bogus. Return -EFAULT and let in wdata_fill_from_iovec()
2813 return -EFAULT; in wdata_fill_from_iovec()
2830 struct TCP_Server_Info *server = wdata->server; in cifs_resend_wdata()
2833 if (wdata->cfile->invalidHandle) { in cifs_resend_wdata()
2834 rc = cifs_reopen_file(wdata->cfile, false); in cifs_resend_wdata()
2835 if (rc == -EAGAIN) in cifs_resend_wdata()
2848 rc = server->ops->wait_mtu_credits(server, wdata->bytes, in cifs_resend_wdata()
2853 if (wsize < wdata->bytes) { in cifs_resend_wdata()
2857 } while (wsize < wdata->bytes); in cifs_resend_wdata()
2858 wdata->credits = credits; in cifs_resend_wdata()
2860 rc = adjust_credits(server, &wdata->credits, wdata->bytes); in cifs_resend_wdata()
2863 if (wdata->cfile->invalidHandle) in cifs_resend_wdata()
2864 rc = -EAGAIN; in cifs_resend_wdata()
2867 if (wdata->mr) { in cifs_resend_wdata()
2868 wdata->mr->need_invalidate = true; in cifs_resend_wdata()
2869 smbd_deregister_mr(wdata->mr); in cifs_resend_wdata()
2870 wdata->mr = NULL; in cifs_resend_wdata()
2873 rc = server->ops->async_writev(wdata, in cifs_resend_wdata()
2880 list_add_tail(&wdata->list, wdata_list); in cifs_resend_wdata()
2885 add_credits_and_wake_if(server, &wdata->credits, 0); in cifs_resend_wdata()
2886 } while (rc == -EAGAIN); in cifs_resend_wdata()
2889 kref_put(&wdata->refcount, cifs_uncached_writedata_release); in cifs_resend_wdata()
2911 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) in cifs_write_from_iter()
2912 pid = open_file->pid; in cifs_write_from_iter()
2914 pid = current->tgid; in cifs_write_from_iter()
2916 server = cifs_pick_channel(tlink_tcon(open_file->tlink)->ses); in cifs_write_from_iter()
2924 if (open_file->invalidHandle) { in cifs_write_from_iter()
2926 if (rc == -EAGAIN) in cifs_write_from_iter()
2932 rc = server->ops->wait_mtu_credits(server, cifs_sb->wsize, in cifs_write_from_iter()
2939 if (ctx->direct_io) { in cifs_write_from_iter()
2948 from->iov_offset, from->count); in cifs_write_from_iter()
2959 (cur_len + start + PAGE_SIZE - 1) / PAGE_SIZE; in cifs_write_from_iter()
2964 rc = -ENOMEM; in cifs_write_from_iter()
2970 wdata->page_offset = start; in cifs_write_from_iter()
2971 wdata->tailsz = in cifs_write_from_iter()
2973 cur_len - (PAGE_SIZE - start) - in cifs_write_from_iter()
2974 (nr_pages - 2) * PAGE_SIZE : in cifs_write_from_iter()
2981 rc = -ENOMEM; in cifs_write_from_iter()
2986 rc = cifs_write_allocate_pages(wdata->pages, nr_pages); in cifs_write_from_iter()
2988 kvfree(wdata->pages); in cifs_write_from_iter()
2999 put_page(wdata->pages[i]); in cifs_write_from_iter()
3000 kvfree(wdata->pages); in cifs_write_from_iter()
3010 for ( ; nr_pages > num_pages; nr_pages--) in cifs_write_from_iter()
3011 put_page(wdata->pages[nr_pages - 1]); in cifs_write_from_iter()
3013 wdata->tailsz = cur_len - ((nr_pages - 1) * PAGE_SIZE); in cifs_write_from_iter()
3016 wdata->sync_mode = WB_SYNC_ALL; in cifs_write_from_iter()
3017 wdata->nr_pages = nr_pages; in cifs_write_from_iter()
3018 wdata->offset = (__u64)offset; in cifs_write_from_iter()
3019 wdata->cfile = cifsFileInfo_get(open_file); in cifs_write_from_iter()
3020 wdata->server = server; in cifs_write_from_iter()
3021 wdata->pid = pid; in cifs_write_from_iter()
3022 wdata->bytes = cur_len; in cifs_write_from_iter()
3023 wdata->pagesz = PAGE_SIZE; in cifs_write_from_iter()
3024 wdata->credits = credits_on_stack; in cifs_write_from_iter()
3025 wdata->ctx = ctx; in cifs_write_from_iter()
3026 kref_get(&ctx->refcount); in cifs_write_from_iter()
3028 rc = adjust_credits(server, &wdata->credits, wdata->bytes); in cifs_write_from_iter()
3031 if (wdata->cfile->invalidHandle) in cifs_write_from_iter()
3032 rc = -EAGAIN; in cifs_write_from_iter()
3034 rc = server->ops->async_writev(wdata, in cifs_write_from_iter()
3039 add_credits_and_wake_if(server, &wdata->credits, 0); in cifs_write_from_iter()
3040 kref_put(&wdata->refcount, in cifs_write_from_iter()
3042 if (rc == -EAGAIN) { in cifs_write_from_iter()
3044 iov_iter_advance(from, offset - saved_offset); in cifs_write_from_iter()
3050 list_add_tail(&wdata->list, wdata_list); in cifs_write_from_iter()
3052 len -= cur_len; in cifs_write_from_iter()
3062 struct cifs_tcon *tcon; in collect_uncached_write_data() local
3064 struct dentry *dentry = ctx->cfile->dentry; in collect_uncached_write_data()
3067 tcon = tlink_tcon(ctx->cfile->tlink); in collect_uncached_write_data()
3068 cifs_sb = CIFS_SB(dentry->d_sb); in collect_uncached_write_data()
3070 mutex_lock(&ctx->aio_mutex); in collect_uncached_write_data()
3072 if (list_empty(&ctx->list)) { in collect_uncached_write_data()
3073 mutex_unlock(&ctx->aio_mutex); in collect_uncached_write_data()
3077 rc = ctx->rc; in collect_uncached_write_data()
3084 list_for_each_entry_safe(wdata, tmp, &ctx->list, list) { in collect_uncached_write_data()
3086 if (!try_wait_for_completion(&wdata->done)) { in collect_uncached_write_data()
3087 mutex_unlock(&ctx->aio_mutex); in collect_uncached_write_data()
3091 if (wdata->result) in collect_uncached_write_data()
3092 rc = wdata->result; in collect_uncached_write_data()
3094 ctx->total_len += wdata->bytes; in collect_uncached_write_data()
3097 if (rc == -EAGAIN) { in collect_uncached_write_data()
3099 struct iov_iter tmp_from = ctx->iter; in collect_uncached_write_data()
3102 list_del_init(&wdata->list); in collect_uncached_write_data()
3104 if (ctx->direct_io) in collect_uncached_write_data()
3109 wdata->offset - ctx->pos); in collect_uncached_write_data()
3111 rc = cifs_write_from_iter(wdata->offset, in collect_uncached_write_data()
3112 wdata->bytes, &tmp_from, in collect_uncached_write_data()
3113 ctx->cfile, cifs_sb, &tmp_list, in collect_uncached_write_data()
3116 kref_put(&wdata->refcount, in collect_uncached_write_data()
3120 list_splice(&tmp_list, &ctx->list); in collect_uncached_write_data()
3124 list_del_init(&wdata->list); in collect_uncached_write_data()
3125 kref_put(&wdata->refcount, cifs_uncached_writedata_release); in collect_uncached_write_data()
3128 cifs_stats_bytes_written(tcon, ctx->total_len); in collect_uncached_write_data()
3129 set_bit(CIFS_INO_INVALID_MAPPING, &CIFS_I(dentry->d_inode)->flags); in collect_uncached_write_data()
3131 ctx->rc = (rc == 0) ? ctx->total_len : rc; in collect_uncached_write_data()
3133 mutex_unlock(&ctx->aio_mutex); in collect_uncached_write_data()
3135 if (ctx->iocb && ctx->iocb->ki_complete) in collect_uncached_write_data()
3136 ctx->iocb->ki_complete(ctx->iocb, ctx->rc, 0); in collect_uncached_write_data()
3138 complete(&ctx->done); in collect_uncached_write_data()
3144 struct file *file = iocb->ki_filp; in __cifs_writev()
3147 struct cifs_tcon *tcon; in __cifs_writev() local
3156 * In this case, fall back to non-direct write function. in __cifs_writev()
3160 cifs_dbg(FYI, "use non-direct cifs_writev for kvec I/O\n"); in __cifs_writev()
3169 cfile = file->private_data; in __cifs_writev()
3170 tcon = tlink_tcon(cfile->tlink); in __cifs_writev()
3172 if (!tcon->ses->server->ops->async_writev) in __cifs_writev()
3173 return -ENOSYS; in __cifs_writev()
3177 return -ENOMEM; in __cifs_writev()
3179 ctx->cfile = cifsFileInfo_get(cfile); in __cifs_writev()
3182 ctx->iocb = iocb; in __cifs_writev()
3184 ctx->pos = iocb->ki_pos; in __cifs_writev()
3187 ctx->direct_io = true; in __cifs_writev()
3188 ctx->iter = *from; in __cifs_writev()
3189 ctx->len = len; in __cifs_writev()
3193 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_writev()
3199 mutex_lock(&ctx->aio_mutex); in __cifs_writev()
3201 rc = cifs_write_from_iter(iocb->ki_pos, ctx->len, &saved_from, in __cifs_writev()
3202 cfile, cifs_sb, &ctx->list, ctx); in __cifs_writev()
3210 if (!list_empty(&ctx->list)) in __cifs_writev()
3213 mutex_unlock(&ctx->aio_mutex); in __cifs_writev()
3216 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_writev()
3221 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_writev()
3222 return -EIOCBQUEUED; in __cifs_writev()
3225 rc = wait_for_completion_killable(&ctx->done); in __cifs_writev()
3227 mutex_lock(&ctx->aio_mutex); in __cifs_writev()
3228 ctx->rc = rc = -EINTR; in __cifs_writev()
3229 total_written = ctx->total_len; in __cifs_writev()
3230 mutex_unlock(&ctx->aio_mutex); in __cifs_writev()
3232 rc = ctx->rc; in __cifs_writev()
3233 total_written = ctx->total_len; in __cifs_writev()
3236 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_writev()
3241 iocb->ki_pos += total_written; in __cifs_writev()
3258 struct file *file = iocb->ki_filp; in cifs_writev()
3259 struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data; in cifs_writev()
3260 struct inode *inode = file->f_mapping->host; in cifs_writev()
3262 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server; in cifs_writev()
3270 down_read(&cinode->lock_sem); in cifs_writev()
3276 if (!cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(from), in cifs_writev()
3277 server->vals->exclusive_lock_type, 0, in cifs_writev()
3281 rc = -EACCES; in cifs_writev()
3283 up_read(&cinode->lock_sem); in cifs_writev()
3294 struct inode *inode = file_inode(iocb->ki_filp); in cifs_strict_writev()
3296 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); in cifs_strict_writev()
3298 iocb->ki_filp->private_data; in cifs_strict_writev()
3299 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); in cifs_strict_writev() local
3307 if (cap_unix(tcon->ses) && in cifs_strict_writev()
3308 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) in cifs_strict_writev()
3309 && ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) { in cifs_strict_writev()
3317 * For non-oplocked files in strict cache mode we need to write the data in cifs_strict_writev()
3318 * to the server exactly from the pos to pos+len-1 rather than flush all in cifs_strict_writev()
3320 * these pages but not on the region from pos to ppos+len-1. in cifs_strict_writev()
3334 cinode->oplock = 0; in cifs_strict_writev()
3348 rdata->pages = pages; in cifs_readdata_direct_alloc()
3349 kref_init(&rdata->refcount); in cifs_readdata_direct_alloc()
3350 INIT_LIST_HEAD(&rdata->list); in cifs_readdata_direct_alloc()
3351 init_completion(&rdata->done); in cifs_readdata_direct_alloc()
3352 INIT_WORK(&rdata->work, complete); in cifs_readdata_direct_alloc()
3380 if (rdata->mr) { in cifs_readdata_release()
3381 smbd_deregister_mr(rdata->mr); in cifs_readdata_release()
3382 rdata->mr = NULL; in cifs_readdata_release()
3385 if (rdata->cfile) in cifs_readdata_release()
3386 cifsFileInfo_put(rdata->cfile); in cifs_readdata_release()
3388 kvfree(rdata->pages); in cifs_readdata_release()
3402 rc = -ENOMEM; in cifs_read_allocate_pages()
3405 rdata->pages[i] = page; in cifs_read_allocate_pages()
3412 put_page(rdata->pages[i]); in cifs_read_allocate_pages()
3413 rdata->pages[i] = NULL; in cifs_read_allocate_pages()
3426 kref_put(&rdata->ctx->refcount, cifs_aio_ctx_release); in cifs_uncached_readdata_release()
3427 for (i = 0; i < rdata->nr_pages; i++) { in cifs_uncached_readdata_release()
3428 put_page(rdata->pages[i]); in cifs_uncached_readdata_release()
3434 * cifs_readdata_to_iov - copy data from pages in response to an iovec
3445 size_t remaining = rdata->got_bytes; in cifs_readdata_to_iov()
3448 for (i = 0; i < rdata->nr_pages; i++) { in cifs_readdata_to_iov()
3449 struct page *page = rdata->pages[i]; in cifs_readdata_to_iov()
3460 remaining -= written; in cifs_readdata_to_iov()
3464 return remaining ? -EFAULT : 0; in cifs_readdata_to_iov()
3475 complete(&rdata->done); in cifs_uncached_readv_complete()
3476 collect_uncached_read_data(rdata->ctx); in cifs_uncached_readv_complete()
3478 kref_put(&rdata->refcount, cifs_uncached_readdata_release); in cifs_uncached_readv_complete()
3488 unsigned int nr_pages = rdata->nr_pages; in uncached_fill_pages()
3489 unsigned int page_offset = rdata->page_offset; in uncached_fill_pages()
3491 rdata->got_bytes = 0; in uncached_fill_pages()
3492 rdata->tailsz = PAGE_SIZE; in uncached_fill_pages()
3494 struct page *page = rdata->pages[i]; in uncached_fill_pages()
3496 unsigned int segment_size = rdata->pagesz; in uncached_fill_pages()
3499 segment_size -= page_offset; in uncached_fill_pages()
3506 rdata->pages[i] = NULL; in uncached_fill_pages()
3507 rdata->nr_pages--; in uncached_fill_pages()
3517 rdata->tailsz = len; in uncached_fill_pages()
3518 len -= n; in uncached_fill_pages()
3524 else if (rdata->mr) in uncached_fill_pages()
3533 rdata->got_bytes += result; in uncached_fill_pages()
3536 return rdata->got_bytes > 0 && result != -ECONNABORTED ? in uncached_fill_pages()
3537 rdata->got_bytes : result; in uncached_fill_pages()
3552 return uncached_fill_pages(server, rdata, iter, iter->count); in cifs_uncached_copy_into_pages()
3564 /* XXX: should we pick a new channel here? */ in cifs_resend_rdata()
3565 server = rdata->server; in cifs_resend_rdata()
3568 if (rdata->cfile->invalidHandle) { in cifs_resend_rdata()
3569 rc = cifs_reopen_file(rdata->cfile, true); in cifs_resend_rdata()
3570 if (rc == -EAGAIN) in cifs_resend_rdata()
3582 rc = server->ops->wait_mtu_credits(server, rdata->bytes, in cifs_resend_rdata()
3588 if (rsize < rdata->bytes) { in cifs_resend_rdata()
3592 } while (rsize < rdata->bytes); in cifs_resend_rdata()
3593 rdata->credits = credits; in cifs_resend_rdata()
3595 rc = adjust_credits(server, &rdata->credits, rdata->bytes); in cifs_resend_rdata()
3597 if (rdata->cfile->invalidHandle) in cifs_resend_rdata()
3598 rc = -EAGAIN; in cifs_resend_rdata()
3601 if (rdata->mr) { in cifs_resend_rdata()
3602 rdata->mr->need_invalidate = true; in cifs_resend_rdata()
3603 smbd_deregister_mr(rdata->mr); in cifs_resend_rdata()
3604 rdata->mr = NULL; in cifs_resend_rdata()
3607 rc = server->ops->async_readv(rdata); in cifs_resend_rdata()
3614 list_add_tail(&rdata->list, rdata_list); in cifs_resend_rdata()
3619 add_credits_and_wake_if(server, &rdata->credits, 0); in cifs_resend_rdata()
3620 } while (rc == -EAGAIN); in cifs_resend_rdata()
3623 kref_put(&rdata->refcount, cifs_uncached_readdata_release); in cifs_resend_rdata()
3642 struct iov_iter direct_iov = ctx->iter; in cifs_send_async_read()
3644 server = cifs_pick_channel(tlink_tcon(open_file->tlink)->ses); in cifs_send_async_read()
3646 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) in cifs_send_async_read()
3647 pid = open_file->pid; in cifs_send_async_read()
3649 pid = current->tgid; in cifs_send_async_read()
3651 if (ctx->direct_io) in cifs_send_async_read()
3652 iov_iter_advance(&direct_iov, offset - ctx->pos); in cifs_send_async_read()
3655 if (open_file->invalidHandle) { in cifs_send_async_read()
3657 if (rc == -EAGAIN) in cifs_send_async_read()
3663 rc = server->ops->wait_mtu_credits(server, cifs_sb->rsize, in cifs_send_async_read()
3670 if (ctx->direct_io) { in cifs_send_async_read()
3695 rc = -ENOMEM; in cifs_send_async_read()
3699 npages = (cur_len + start + PAGE_SIZE-1) / PAGE_SIZE; in cifs_send_async_read()
3700 rdata->page_offset = start; in cifs_send_async_read()
3701 rdata->tailsz = npages > 1 ? in cifs_send_async_read()
3702 cur_len-(PAGE_SIZE-start)-(npages-2)*PAGE_SIZE : in cifs_send_async_read()
3713 rc = -ENOMEM; in cifs_send_async_read()
3719 kvfree(rdata->pages); in cifs_send_async_read()
3725 rdata->tailsz = PAGE_SIZE; in cifs_send_async_read()
3728 rdata->server = server; in cifs_send_async_read()
3729 rdata->cfile = cifsFileInfo_get(open_file); in cifs_send_async_read()
3730 rdata->nr_pages = npages; in cifs_send_async_read()
3731 rdata->offset = offset; in cifs_send_async_read()
3732 rdata->bytes = cur_len; in cifs_send_async_read()
3733 rdata->pid = pid; in cifs_send_async_read()
3734 rdata->pagesz = PAGE_SIZE; in cifs_send_async_read()
3735 rdata->read_into_pages = cifs_uncached_read_into_pages; in cifs_send_async_read()
3736 rdata->copy_into_pages = cifs_uncached_copy_into_pages; in cifs_send_async_read()
3737 rdata->credits = credits_on_stack; in cifs_send_async_read()
3738 rdata->ctx = ctx; in cifs_send_async_read()
3739 kref_get(&ctx->refcount); in cifs_send_async_read()
3741 rc = adjust_credits(server, &rdata->credits, rdata->bytes); in cifs_send_async_read()
3744 if (rdata->cfile->invalidHandle) in cifs_send_async_read()
3745 rc = -EAGAIN; in cifs_send_async_read()
3747 rc = server->ops->async_readv(rdata); in cifs_send_async_read()
3751 add_credits_and_wake_if(server, &rdata->credits, 0); in cifs_send_async_read()
3752 kref_put(&rdata->refcount, in cifs_send_async_read()
3754 if (rc == -EAGAIN) { in cifs_send_async_read()
3761 list_add_tail(&rdata->list, rdata_list); in cifs_send_async_read()
3763 len -= cur_len; in cifs_send_async_read()
3773 struct iov_iter *to = &ctx->iter; in collect_uncached_read_data()
3777 cifs_sb = CIFS_SB(ctx->cfile->dentry->d_sb); in collect_uncached_read_data()
3779 mutex_lock(&ctx->aio_mutex); in collect_uncached_read_data()
3781 if (list_empty(&ctx->list)) { in collect_uncached_read_data()
3782 mutex_unlock(&ctx->aio_mutex); in collect_uncached_read_data()
3786 rc = ctx->rc; in collect_uncached_read_data()
3789 list_for_each_entry_safe(rdata, tmp, &ctx->list, list) { in collect_uncached_read_data()
3791 if (!try_wait_for_completion(&rdata->done)) { in collect_uncached_read_data()
3792 mutex_unlock(&ctx->aio_mutex); in collect_uncached_read_data()
3796 if (rdata->result == -EAGAIN) { in collect_uncached_read_data()
3799 unsigned int got_bytes = rdata->got_bytes; in collect_uncached_read_data()
3801 list_del_init(&rdata->list); in collect_uncached_read_data()
3806 * happened -- fill the buffer and continue in collect_uncached_read_data()
3809 if (got_bytes && got_bytes < rdata->bytes) { in collect_uncached_read_data()
3811 if (!ctx->direct_io) in collect_uncached_read_data()
3814 kref_put(&rdata->refcount, in collect_uncached_read_data()
3820 if (ctx->direct_io) { in collect_uncached_read_data()
3822 * Re-use rdata as this is a in collect_uncached_read_data()
3830 rdata->offset + got_bytes, in collect_uncached_read_data()
3831 rdata->bytes - got_bytes, in collect_uncached_read_data()
3832 rdata->cfile, cifs_sb, in collect_uncached_read_data()
3835 kref_put(&rdata->refcount, in collect_uncached_read_data()
3839 list_splice(&tmp_list, &ctx->list); in collect_uncached_read_data()
3842 } else if (rdata->result) in collect_uncached_read_data()
3843 rc = rdata->result; in collect_uncached_read_data()
3844 else if (!ctx->direct_io) in collect_uncached_read_data()
3847 /* if there was a short read -- discard anything left */ in collect_uncached_read_data()
3848 if (rdata->got_bytes && rdata->got_bytes < rdata->bytes) in collect_uncached_read_data()
3849 rc = -ENODATA; in collect_uncached_read_data()
3851 ctx->total_len += rdata->got_bytes; in collect_uncached_read_data()
3853 list_del_init(&rdata->list); in collect_uncached_read_data()
3854 kref_put(&rdata->refcount, cifs_uncached_readdata_release); in collect_uncached_read_data()
3857 if (!ctx->direct_io) in collect_uncached_read_data()
3858 ctx->total_len = ctx->len - iov_iter_count(to); in collect_uncached_read_data()
3861 if (rc == -ENODATA) in collect_uncached_read_data()
3864 ctx->rc = (rc == 0) ? (ssize_t)ctx->total_len : rc; in collect_uncached_read_data()
3866 mutex_unlock(&ctx->aio_mutex); in collect_uncached_read_data()
3868 if (ctx->iocb && ctx->iocb->ki_complete) in collect_uncached_read_data()
3869 ctx->iocb->ki_complete(ctx->iocb, ctx->rc, 0); in collect_uncached_read_data()
3871 complete(&ctx->done); in collect_uncached_read_data()
3878 struct file *file = iocb->ki_filp; in __cifs_readv()
3881 struct cifs_tcon *tcon; in __cifs_readv() local
3883 loff_t offset = iocb->ki_pos; in __cifs_readv()
3892 cifs_dbg(FYI, "use non-direct cifs_user_readv for kvec I/O\n"); in __cifs_readv()
3901 cfile = file->private_data; in __cifs_readv()
3902 tcon = tlink_tcon(cfile->tlink); in __cifs_readv()
3904 if (!tcon->ses->server->ops->async_readv) in __cifs_readv()
3905 return -ENOSYS; in __cifs_readv()
3907 if ((file->f_flags & O_ACCMODE) == O_WRONLY) in __cifs_readv()
3912 return -ENOMEM; in __cifs_readv()
3914 ctx->cfile = cifsFileInfo_get(cfile); in __cifs_readv()
3917 ctx->iocb = iocb; in __cifs_readv()
3920 ctx->should_dirty = true; in __cifs_readv()
3923 ctx->pos = offset; in __cifs_readv()
3924 ctx->direct_io = true; in __cifs_readv()
3925 ctx->iter = *to; in __cifs_readv()
3926 ctx->len = len; in __cifs_readv()
3930 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_readv()
3933 len = ctx->len; in __cifs_readv()
3937 mutex_lock(&ctx->aio_mutex); in __cifs_readv()
3939 rc = cifs_send_async_read(offset, len, cfile, cifs_sb, &ctx->list, ctx); in __cifs_readv()
3942 if (!list_empty(&ctx->list)) in __cifs_readv()
3945 mutex_unlock(&ctx->aio_mutex); in __cifs_readv()
3948 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_readv()
3953 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_readv()
3954 return -EIOCBQUEUED; in __cifs_readv()
3957 rc = wait_for_completion_killable(&ctx->done); in __cifs_readv()
3959 mutex_lock(&ctx->aio_mutex); in __cifs_readv()
3960 ctx->rc = rc = -EINTR; in __cifs_readv()
3961 total_read = ctx->total_len; in __cifs_readv()
3962 mutex_unlock(&ctx->aio_mutex); in __cifs_readv()
3964 rc = ctx->rc; in __cifs_readv()
3965 total_read = ctx->total_len; in __cifs_readv()
3968 kref_put(&ctx->refcount, cifs_aio_ctx_release); in __cifs_readv()
3971 iocb->ki_pos += total_read; in __cifs_readv()
3990 struct inode *inode = file_inode(iocb->ki_filp); in cifs_strict_readv()
3992 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); in cifs_strict_readv()
3994 iocb->ki_filp->private_data; in cifs_strict_readv()
3995 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); in cifs_strict_readv() local
3996 int rc = -EACCES; in cifs_strict_readv()
4001 * change - so we can't make a decision about inode invalidating. in cifs_strict_readv()
4004 * pos+len-1. in cifs_strict_readv()
4009 if (cap_unix(tcon->ses) && in cifs_strict_readv()
4010 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && in cifs_strict_readv()
4011 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) in cifs_strict_readv()
4018 down_read(&cinode->lock_sem); in cifs_strict_readv()
4019 if (!cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(to), in cifs_strict_readv()
4020 tcon->ses->server->vals->shared_lock_type, in cifs_strict_readv()
4023 up_read(&cinode->lock_sem); in cifs_strict_readv()
4030 int rc = -EACCES; in cifs_read()
4036 struct cifs_tcon *tcon; in cifs_read() local
4049 rsize = min_t(unsigned int, cifs_sb->rsize, CIFSMaxBufSize); in cifs_read()
4051 if (file->private_data == NULL) { in cifs_read()
4052 rc = -EBADF; in cifs_read()
4056 open_file = file->private_data; in cifs_read()
4057 tcon = tlink_tcon(open_file->tlink); in cifs_read()
4058 server = cifs_pick_channel(tcon->ses); in cifs_read()
4060 if (!server->ops->sync_read) { in cifs_read()
4062 return -ENOSYS; in cifs_read()
4065 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) in cifs_read()
4066 pid = open_file->pid; in cifs_read()
4068 pid = current->tgid; in cifs_read()
4070 if ((file->f_flags & O_ACCMODE) == O_WRONLY) in cifs_read()
4076 current_read_size = min_t(uint, read_size - total_read, in cifs_read()
4083 if (!(tcon->ses->capabilities & in cifs_read()
4084 tcon->ses->server->vals->cap_large_files)) { in cifs_read()
4088 if (open_file->invalidHandle) { in cifs_read()
4094 io_parms.tcon = tcon; in cifs_read()
4098 rc = server->ops->sync_read(xid, &open_file->fid, &io_parms, in cifs_read()
4101 } while (rc == -EAGAIN); in cifs_read()
4111 cifs_stats_bytes_read(tcon, total_read); in cifs_read()
4126 struct page *page = vmf->page; in cifs_page_mkwrite()
4150 vma->vm_ops = &cifs_file_vm_ops; in cifs_file_strict_mmap()
4169 vma->vm_ops = &cifs_file_vm_ops; in cifs_file_mmap()
4182 got_bytes = rdata->got_bytes; in cifs_readv_complete()
4183 for (i = 0; i < rdata->nr_pages; i++) { in cifs_readv_complete()
4184 struct page *page = rdata->pages[i]; in cifs_readv_complete()
4188 if (rdata->result == 0 || in cifs_readv_complete()
4189 (rdata->result == -EAGAIN && got_bytes)) { in cifs_readv_complete()
4196 if (rdata->result == 0 || in cifs_readv_complete()
4197 (rdata->result == -EAGAIN && got_bytes)) in cifs_readv_complete()
4198 cifs_readpage_to_fscache(rdata->mapping->host, page); in cifs_readv_complete()
4200 got_bytes -= min_t(unsigned int, PAGE_SIZE, got_bytes); in cifs_readv_complete()
4203 rdata->pages[i] = NULL; in cifs_readv_complete()
4205 kref_put(&rdata->refcount, cifs_readdata_release); in cifs_readv_complete()
4217 unsigned int nr_pages = rdata->nr_pages; in readpages_fill_pages()
4218 unsigned int page_offset = rdata->page_offset; in readpages_fill_pages()
4221 eof = CIFS_I(rdata->mapping->host)->server_eof; in readpages_fill_pages()
4222 eof_index = eof ? (eof - 1) >> PAGE_SHIFT : 0; in readpages_fill_pages()
4225 rdata->got_bytes = 0; in readpages_fill_pages()
4226 rdata->tailsz = PAGE_SIZE; in readpages_fill_pages()
4228 struct page *page = rdata->pages[i]; in readpages_fill_pages()
4229 unsigned int to_read = rdata->pagesz; in readpages_fill_pages()
4233 to_read -= page_offset; in readpages_fill_pages()
4240 len -= to_read; in readpages_fill_pages()
4243 zero_user(page, len + page_offset, to_read - len); in readpages_fill_pages()
4244 n = rdata->tailsz = len; in readpages_fill_pages()
4246 } else if (page->index > eof_index) { in readpages_fill_pages()
4261 rdata->pages[i] = NULL; in readpages_fill_pages()
4262 rdata->nr_pages--; in readpages_fill_pages()
4269 rdata->pages[i] = NULL; in readpages_fill_pages()
4270 rdata->nr_pages--; in readpages_fill_pages()
4278 else if (rdata->mr) in readpages_fill_pages()
4287 rdata->got_bytes += result; in readpages_fill_pages()
4290 return rdata->got_bytes > 0 && result != -ECONNABORTED ? in readpages_fill_pages()
4291 rdata->got_bytes : result; in readpages_fill_pages()
4306 return readpages_fill_pages(server, rdata, iter, iter->count); in cifs_readpages_copy_into_pages()
4330 page->index, gfp); in readpages_get_pages()
4339 *offset = (loff_t)page->index << PAGE_SHIFT; in readpages_get_pages()
4342 list_move_tail(&page->lru, tmplist); in readpages_get_pages()
4345 expected_index = page->index + 1; in readpages_get_pages()
4348 if (page->index != expected_index) in readpages_get_pages()
4356 rc = add_to_page_cache_locked(page, mapping, page->index, gfp); in readpages_get_pages()
4361 list_move_tail(&page->lru, tmplist); in readpages_get_pages()
4375 struct cifsFileInfo *open_file = file->private_data; in cifs_readpages()
4383 * Reads as many pages as possible from fscache. Returns -ENOBUFS in cifs_readpages()
4389 rc = cifs_readpages_from_fscache(mapping->host, mapping, page_list, in cifs_readpages()
4396 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) in cifs_readpages()
4397 pid = open_file->pid; in cifs_readpages()
4399 pid = current->tgid; in cifs_readpages()
4402 server = cifs_pick_channel(tlink_tcon(open_file->tlink)->ses); in cifs_readpages()
4416 * the rdata->pages, then we want them in increasing order. in cifs_readpages()
4426 if (open_file->invalidHandle) { in cifs_readpages()
4428 if (rc == -EAGAIN) in cifs_readpages()
4434 rc = server->ops->wait_mtu_credits(server, cifs_sb->rsize, in cifs_readpages()
4463 list_del(&page->lru); in cifs_readpages()
4468 rc = -ENOMEM; in cifs_readpages()
4473 rdata->cfile = cifsFileInfo_get(open_file); in cifs_readpages()
4474 rdata->server = server; in cifs_readpages()
4475 rdata->mapping = mapping; in cifs_readpages()
4476 rdata->offset = offset; in cifs_readpages()
4477 rdata->bytes = bytes; in cifs_readpages()
4478 rdata->pid = pid; in cifs_readpages()
4479 rdata->pagesz = PAGE_SIZE; in cifs_readpages()
4480 rdata->tailsz = PAGE_SIZE; in cifs_readpages()
4481 rdata->read_into_pages = cifs_readpages_read_into_pages; in cifs_readpages()
4482 rdata->copy_into_pages = cifs_readpages_copy_into_pages; in cifs_readpages()
4483 rdata->credits = credits_on_stack; in cifs_readpages()
4486 list_del(&page->lru); in cifs_readpages()
4487 rdata->pages[rdata->nr_pages++] = page; in cifs_readpages()
4490 rc = adjust_credits(server, &rdata->credits, rdata->bytes); in cifs_readpages()
4493 if (rdata->cfile->invalidHandle) in cifs_readpages()
4494 rc = -EAGAIN; in cifs_readpages()
4496 rc = server->ops->async_readv(rdata); in cifs_readpages()
4500 add_credits_and_wake_if(server, &rdata->credits, 0); in cifs_readpages()
4501 for (i = 0; i < rdata->nr_pages; i++) { in cifs_readpages()
4502 page = rdata->pages[i]; in cifs_readpages()
4508 kref_put(&rdata->refcount, cifs_readdata_release); in cifs_readpages()
4512 kref_put(&rdata->refcount, cifs_readdata_release); in cifs_readpages()
4519 cifs_fscache_readpages_cancel(mapping->host, page_list); in cifs_readpages()
4549 file_inode(file)->i_atime = current_time(file_inode(file)); in cifs_readpage_worker()
4550 if (timespec64_compare(&(file_inode(file)->i_atime), &(file_inode(file)->i_mtime))) in cifs_readpage_worker()
4551 file_inode(file)->i_atime = file_inode(file)->i_mtime; in cifs_readpage_worker()
4553 file_inode(file)->i_atime = current_time(file_inode(file)); in cifs_readpage_worker()
4556 memset(read_data + rc, 0, PAGE_SIZE - rc); in cifs_readpage_worker()
4577 int rc = -EACCES; in cifs_readpage()
4582 if (file->private_data == NULL) { in cifs_readpage()
4583 rc = -EBADF; in cifs_readpage()
4601 spin_lock(&cifs_inode->open_file_lock); in is_inode_writable()
4602 list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { in is_inode_writable()
4603 if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) { in is_inode_writable()
4604 spin_unlock(&cifs_inode->open_file_lock); in is_inode_writable()
4608 spin_unlock(&cifs_inode->open_file_lock); in is_inode_writable()
4613 open for write - to avoid races with writepage extending
4614 the file - in the future we could consider allowing
4627 cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb); in is_size_safe_to_change()
4628 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { in is_size_safe_to_change()
4634 if (i_size_read(&cifsInode->vfs_inode) < end_of_file) in is_size_safe_to_change()
4648 loff_t offset = pos & (PAGE_SIZE - 1); in cifs_write_begin()
4659 rc = -ENOMEM; in cifs_write_begin()
4680 if (CIFS_CACHE_READ(CIFS_I(mapping->host))) { in cifs_write_begin()
4681 i_size = i_size_read(mapping->host); in cifs_write_begin()
4698 if ((file->f_flags & O_ACCMODE) != O_WRONLY && !oncethru) { in cifs_write_begin()
4709 /* we could try using another file handle if there is one - in cifs_write_begin()
4730 struct cifsInodeInfo *cifsi = CIFS_I(page->mapping->host); in cifs_invalidate_page()
4733 cifs_fscache_invalidate_page(page, &cifsi->vfs_inode); in cifs_invalidate_page()
4740 loff_t range_end = range_start + (loff_t)(PAGE_SIZE - 1); in cifs_launder_page()
4753 cifs_fscache_invalidate_page(page, page->mapping->host); in cifs_launder_page()
4761 struct inode *inode = d_inode(cfile->dentry); in cifs_oplock_break()
4763 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); in cifs_oplock_break() local
4764 struct TCP_Server_Info *server = tcon->ses->server; in cifs_oplock_break()
4768 wait_on_bit(&cinode->flags, CIFS_INODE_PENDING_WRITERS, in cifs_oplock_break()
4771 server->ops->downgrade_oplock(server, cinode, cfile->oplock_level, in cifs_oplock_break()
4772 cfile->oplock_epoch, &purge_cache); in cifs_oplock_break()
4778 cinode->oplock = 0; in cifs_oplock_break()
4781 if (inode && S_ISREG(inode->i_mode)) { in cifs_oplock_break()
4786 rc = filemap_fdatawrite(inode->i_mapping); in cifs_oplock_break()
4788 rc = filemap_fdatawait(inode->i_mapping); in cifs_oplock_break()
4789 mapping_set_error(inode->i_mapping, rc); in cifs_oplock_break()
4808 if (!cfile->oplock_break_cancelled) { in cifs_oplock_break()
4809 rc = tcon->ses->server->ops->oplock_response(tcon, &cfile->fid, in cifs_oplock_break()
4821 * In the non-cached mode (mount with cache=none), we shunt off direct read and write requests
4833 return -EINVAL; in cifs_direct_io()
4839 struct cifsFileInfo *cfile = swap_file->private_data; in cifs_swap_activate()
4840 struct inode *inode = swap_file->f_mapping->host; in cifs_swap_activate()
4846 spin_lock(&inode->i_lock); in cifs_swap_activate()
4847 blocks = inode->i_blocks; in cifs_swap_activate()
4848 isize = inode->i_size; in cifs_swap_activate()
4849 spin_unlock(&inode->i_lock); in cifs_swap_activate()
4852 return -EINVAL; in cifs_swap_activate()
4854 *span = sis->pages; in cifs_swap_activate()
4867 cfile->swapfile = true; in cifs_swap_activate()
4879 struct cifsFileInfo *cfile = file->private_data; in cifs_swap_deactivate()
4886 cfile->swapfile = false; in cifs_swap_deactivate()