diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-02-15 15:55:05 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2008-02-15 15:55:05 -0500 |
commit | 70eff55d2d979cca700aa6906494f0c474f3f7ff (patch) | |
tree | 12ad361db592321c3d2a0fb51cf7f47a22d27d6b /fs/cifs/inode.c | |
parent | c2d68ea65b0f668783c88e1f4f22738b24f3edea (diff) |
[CIFS] factoring out common code in get_inode_info functions
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/inode.c')
-rw-r--r-- | fs/cifs/inode.c | 106 |
1 files changed, 43 insertions, 63 deletions
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 6020add1515..e7cd392a796 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -29,6 +29,46 @@ | |||
29 | #include "cifs_debug.h" | 29 | #include "cifs_debug.h" |
30 | #include "cifs_fs_sb.h" | 30 | #include "cifs_fs_sb.h" |
31 | 31 | ||
32 | |||
33 | static void cifs_set_ops(struct inode *inode) | ||
34 | { | ||
35 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); | ||
36 | |||
37 | switch (inode->i_mode & S_IFMT) { | ||
38 | case S_IFREG: | ||
39 | inode->i_op = &cifs_file_inode_ops; | ||
40 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { | ||
41 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | ||
42 | inode->i_fop = &cifs_file_direct_nobrl_ops; | ||
43 | else | ||
44 | inode->i_fop = &cifs_file_direct_ops; | ||
45 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | ||
46 | inode->i_fop = &cifs_file_nobrl_ops; | ||
47 | else { /* not direct, send byte range locks */ | ||
48 | inode->i_fop = &cifs_file_ops; | ||
49 | } | ||
50 | |||
51 | |||
52 | /* check if server can support readpages */ | ||
53 | if (cifs_sb->tcon->ses->server->maxBuf < | ||
54 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) | ||
55 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; | ||
56 | else | ||
57 | inode->i_data.a_ops = &cifs_addr_ops; | ||
58 | break; | ||
59 | case S_IFDIR: | ||
60 | inode->i_op = &cifs_dir_inode_ops; | ||
61 | inode->i_fop = &cifs_dir_ops; | ||
62 | break; | ||
63 | case S_IFLNK: | ||
64 | inode->i_op = &cifs_symlink_inode_ops; | ||
65 | break; | ||
66 | default: | ||
67 | init_special_inode(inode, inode->i_mode, inode->i_rdev); | ||
68 | break; | ||
69 | } | ||
70 | } | ||
71 | |||
32 | int cifs_get_inode_info_unix(struct inode **pinode, | 72 | int cifs_get_inode_info_unix(struct inode **pinode, |
33 | const unsigned char *search_path, struct super_block *sb, int xid) | 73 | const unsigned char *search_path, struct super_block *sb, int xid) |
34 | { | 74 | { |
@@ -178,39 +218,8 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
178 | cFYI(1, ("Size %ld and blocks %llu", | 218 | cFYI(1, ("Size %ld and blocks %llu", |
179 | (unsigned long) inode->i_size, | 219 | (unsigned long) inode->i_size, |
180 | (unsigned long long)inode->i_blocks)); | 220 | (unsigned long long)inode->i_blocks)); |
181 | if (S_ISREG(inode->i_mode)) { | 221 | |
182 | cFYI(1, ("File inode")); | 222 | cifs_set_ops(inode); |
183 | inode->i_op = &cifs_file_inode_ops; | ||
184 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { | ||
185 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | ||
186 | inode->i_fop = | ||
187 | &cifs_file_direct_nobrl_ops; | ||
188 | else | ||
189 | inode->i_fop = &cifs_file_direct_ops; | ||
190 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | ||
191 | inode->i_fop = &cifs_file_nobrl_ops; | ||
192 | else /* not direct, send byte range locks */ | ||
193 | inode->i_fop = &cifs_file_ops; | ||
194 | |||
195 | /* check if server can support readpages */ | ||
196 | if (pTcon->ses->server->maxBuf < | ||
197 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) | ||
198 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; | ||
199 | else | ||
200 | inode->i_data.a_ops = &cifs_addr_ops; | ||
201 | } else if (S_ISDIR(inode->i_mode)) { | ||
202 | cFYI(1, ("Directory inode")); | ||
203 | inode->i_op = &cifs_dir_inode_ops; | ||
204 | inode->i_fop = &cifs_dir_ops; | ||
205 | } else if (S_ISLNK(inode->i_mode)) { | ||
206 | cFYI(1, ("Symbolic Link inode")); | ||
207 | inode->i_op = &cifs_symlink_inode_ops; | ||
208 | /* tmp_inode->i_fop = */ /* do not need to set to anything */ | ||
209 | } else { | ||
210 | cFYI(1, ("Init special inode")); | ||
211 | init_special_inode(inode, inode->i_mode, | ||
212 | inode->i_rdev); | ||
213 | } | ||
214 | } | 223 | } |
215 | return rc; | 224 | return rc; |
216 | } | 225 | } |
@@ -546,36 +555,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
546 | atomic_set(&cifsInfo->inUse, 1); | 555 | atomic_set(&cifsInfo->inUse, 1); |
547 | } | 556 | } |
548 | 557 | ||
549 | if (S_ISREG(inode->i_mode)) { | 558 | cifs_set_ops(inode); |
550 | cFYI(1, ("File inode")); | ||
551 | inode->i_op = &cifs_file_inode_ops; | ||
552 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { | ||
553 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | ||
554 | inode->i_fop = | ||
555 | &cifs_file_direct_nobrl_ops; | ||
556 | else | ||
557 | inode->i_fop = &cifs_file_direct_ops; | ||
558 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | ||
559 | inode->i_fop = &cifs_file_nobrl_ops; | ||
560 | else /* not direct, send byte range locks */ | ||
561 | inode->i_fop = &cifs_file_ops; | ||
562 | |||
563 | if (pTcon->ses->server->maxBuf < | ||
564 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) | ||
565 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; | ||
566 | else | ||
567 | inode->i_data.a_ops = &cifs_addr_ops; | ||
568 | } else if (S_ISDIR(inode->i_mode)) { | ||
569 | cFYI(1, ("Directory inode")); | ||
570 | inode->i_op = &cifs_dir_inode_ops; | ||
571 | inode->i_fop = &cifs_dir_ops; | ||
572 | } else if (S_ISLNK(inode->i_mode)) { | ||
573 | cFYI(1, ("Symbolic Link inode")); | ||
574 | inode->i_op = &cifs_symlink_inode_ops; | ||
575 | } else { | ||
576 | init_special_inode(inode, inode->i_mode, | ||
577 | inode->i_rdev); | ||
578 | } | ||
579 | } | 559 | } |
580 | kfree(buf); | 560 | kfree(buf); |
581 | return rc; | 561 | return rc; |