diff options
author | Pavel Shilovsky <pshilovsky@samba.org> | 2012-09-18 19:20:32 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-09-24 22:46:29 -0400 |
commit | 92fc65a74a2be1388d774f7dbf82c9adea1745cf (patch) | |
tree | 262ccb0fcb9edbf09cd2480facaa9135ec511088 /fs/cifs/file.c | |
parent | 1feeaac753e0a9b3864740556b7840643642abdb (diff) |
CIFS: Move readdir code to ops struct
Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r-- | fs/cifs/file.c | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 39fff77e38d4..fb6b4413255b 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -618,39 +618,47 @@ int cifs_closedir(struct inode *inode, struct file *file) | |||
618 | int rc = 0; | 618 | int rc = 0; |
619 | unsigned int xid; | 619 | unsigned int xid; |
620 | struct cifsFileInfo *cfile = file->private_data; | 620 | struct cifsFileInfo *cfile = file->private_data; |
621 | char *tmp; | 621 | struct cifs_tcon *tcon; |
622 | struct TCP_Server_Info *server; | ||
623 | char *buf; | ||
622 | 624 | ||
623 | cFYI(1, "Closedir inode = 0x%p", inode); | 625 | cFYI(1, "Closedir inode = 0x%p", inode); |
624 | 626 | ||
627 | if (cfile == NULL) | ||
628 | return rc; | ||
629 | |||
625 | xid = get_xid(); | 630 | xid = get_xid(); |
631 | tcon = tlink_tcon(cfile->tlink); | ||
632 | server = tcon->ses->server; | ||
626 | 633 | ||
627 | if (cfile) { | 634 | cFYI(1, "Freeing private data in close dir"); |
628 | struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); | 635 | spin_lock(&cifs_file_list_lock); |
636 | if (!cfile->srch_inf.endOfSearch && !cfile->invalidHandle) { | ||
637 | cfile->invalidHandle = true; | ||
638 | spin_unlock(&cifs_file_list_lock); | ||
639 | if (server->ops->close_dir) | ||
640 | rc = server->ops->close_dir(xid, tcon, &cfile->fid); | ||
641 | else | ||
642 | rc = -ENOSYS; | ||
643 | cFYI(1, "Closing uncompleted readdir with rc %d", rc); | ||
644 | /* not much we can do if it fails anyway, ignore rc */ | ||
645 | rc = 0; | ||
646 | } else | ||
647 | spin_unlock(&cifs_file_list_lock); | ||
629 | 648 | ||
630 | cFYI(1, "Freeing private data in close dir"); | 649 | buf = cfile->srch_inf.ntwrk_buf_start; |
631 | spin_lock(&cifs_file_list_lock); | 650 | if (buf) { |
632 | if (!cfile->srch_inf.endOfSearch && !cfile->invalidHandle) { | 651 | cFYI(1, "closedir free smb buf in srch struct"); |
633 | cfile->invalidHandle = true; | 652 | cfile->srch_inf.ntwrk_buf_start = NULL; |
634 | spin_unlock(&cifs_file_list_lock); | 653 | if (cfile->srch_inf.smallBuf) |
635 | rc = CIFSFindClose(xid, tcon, cfile->fid.netfid); | 654 | cifs_small_buf_release(buf); |
636 | cFYI(1, "Closing uncompleted readdir with rc %d", rc); | 655 | else |
637 | /* not much we can do if it fails anyway, ignore rc */ | 656 | cifs_buf_release(buf); |
638 | rc = 0; | ||
639 | } else | ||
640 | spin_unlock(&cifs_file_list_lock); | ||
641 | tmp = cfile->srch_inf.ntwrk_buf_start; | ||
642 | if (tmp) { | ||
643 | cFYI(1, "closedir free smb buf in srch struct"); | ||
644 | cfile->srch_inf.ntwrk_buf_start = NULL; | ||
645 | if (cfile->srch_inf.smallBuf) | ||
646 | cifs_small_buf_release(tmp); | ||
647 | else | ||
648 | cifs_buf_release(tmp); | ||
649 | } | ||
650 | cifs_put_tlink(cfile->tlink); | ||
651 | kfree(file->private_data); | ||
652 | file->private_data = NULL; | ||
653 | } | 657 | } |
658 | |||
659 | cifs_put_tlink(cfile->tlink); | ||
660 | kfree(file->private_data); | ||
661 | file->private_data = NULL; | ||
654 | /* BB can we lock the filestruct while this is going on? */ | 662 | /* BB can we lock the filestruct while this is going on? */ |
655 | free_xid(xid); | 663 | free_xid(xid); |
656 | return rc; | 664 | return rc; |