diff options
Diffstat (limited to 'fs/cifs/inode.c')
-rw-r--r-- | fs/cifs/inode.c | 104 |
1 files changed, 64 insertions, 40 deletions
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index bcf7b5184664..4690a360c855 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -199,6 +199,49 @@ static void fill_fake_finddataunix(FILE_UNIX_BASIC_INFO *pfnd_dat, | |||
199 | pfnd_dat->Gid = cpu_to_le64(pinode->i_gid); | 199 | pfnd_dat->Gid = cpu_to_le64(pinode->i_gid); |
200 | } | 200 | } |
201 | 201 | ||
202 | /** | ||
203 | * cifs_new inode - create new inode, initialize, and hash it | ||
204 | * @sb - pointer to superblock | ||
205 | * @inum - if valid pointer and serverino is enabled, replace i_ino with val | ||
206 | * | ||
207 | * Create a new inode, initialize it for CIFS and hash it. Returns the new | ||
208 | * inode or NULL if one couldn't be allocated. | ||
209 | * | ||
210 | * If the share isn't mounted with "serverino" or inum is a NULL pointer then | ||
211 | * we'll just use the inode number assigned by new_inode(). Note that this can | ||
212 | * mean i_ino collisions since the i_ino assigned by new_inode is not | ||
213 | * guaranteed to be unique. | ||
214 | */ | ||
215 | struct inode * | ||
216 | cifs_new_inode(struct super_block *sb, __u64 *inum) | ||
217 | { | ||
218 | struct inode *inode; | ||
219 | |||
220 | inode = new_inode(sb); | ||
221 | if (inode == NULL) | ||
222 | return NULL; | ||
223 | |||
224 | /* | ||
225 | * BB: Is i_ino == 0 legal? Here, we assume that it is. If it isn't we | ||
226 | * stop passing inum as ptr. Are there sanity checks we can use to | ||
227 | * ensure that the server is really filling in that field? Also, | ||
228 | * if serverino is disabled, perhaps we should be using iunique()? | ||
229 | */ | ||
230 | if (inum && (CIFS_SB(sb)->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) | ||
231 | inode->i_ino = (unsigned long) *inum; | ||
232 | |||
233 | /* | ||
234 | * must set this here instead of cifs_alloc_inode since VFS will | ||
235 | * clobber i_flags | ||
236 | */ | ||
237 | if (sb->s_flags & MS_NOATIME) | ||
238 | inode->i_flags |= S_NOATIME | S_NOCMTIME; | ||
239 | |||
240 | insert_inode_hash(inode); | ||
241 | |||
242 | return inode; | ||
243 | } | ||
244 | |||
202 | int cifs_get_inode_info_unix(struct inode **pinode, | 245 | int cifs_get_inode_info_unix(struct inode **pinode, |
203 | const unsigned char *full_path, struct super_block *sb, int xid) | 246 | const unsigned char *full_path, struct super_block *sb, int xid) |
204 | { | 247 | { |
@@ -233,22 +276,11 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
233 | 276 | ||
234 | /* get new inode */ | 277 | /* get new inode */ |
235 | if (*pinode == NULL) { | 278 | if (*pinode == NULL) { |
236 | *pinode = new_inode(sb); | 279 | *pinode = cifs_new_inode(sb, &find_data.UniqueId); |
237 | if (*pinode == NULL) { | 280 | if (*pinode == NULL) { |
238 | rc = -ENOMEM; | 281 | rc = -ENOMEM; |
239 | goto cgiiu_exit; | 282 | goto cgiiu_exit; |
240 | } | 283 | } |
241 | /* Is an i_ino of zero legal? */ | ||
242 | /* note ino incremented to unique num in new_inode */ | ||
243 | /* Are there sanity checks we can use to ensure that | ||
244 | the server is really filling in that field? */ | ||
245 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) | ||
246 | (*pinode)->i_ino = (unsigned long)find_data.UniqueId; | ||
247 | |||
248 | if (sb->s_flags & MS_NOATIME) | ||
249 | (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME; | ||
250 | |||
251 | insert_inode_hash(*pinode); | ||
252 | } | 284 | } |
253 | 285 | ||
254 | inode = *pinode; | 286 | inode = *pinode; |
@@ -465,11 +497,9 @@ int cifs_get_inode_info(struct inode **pinode, | |||
465 | 497 | ||
466 | /* get new inode */ | 498 | /* get new inode */ |
467 | if (*pinode == NULL) { | 499 | if (*pinode == NULL) { |
468 | *pinode = new_inode(sb); | 500 | __u64 inode_num; |
469 | if (*pinode == NULL) { | 501 | __u64 *pinum = &inode_num; |
470 | rc = -ENOMEM; | 502 | |
471 | goto cgii_exit; | ||
472 | } | ||
473 | /* Is an i_ino of zero legal? Can we use that to check | 503 | /* Is an i_ino of zero legal? Can we use that to check |
474 | if the server supports returning inode numbers? Are | 504 | if the server supports returning inode numbers? Are |
475 | there other sanity checks we can use to ensure that | 505 | there other sanity checks we can use to ensure that |
@@ -486,22 +516,26 @@ int cifs_get_inode_info(struct inode **pinode, | |||
486 | 516 | ||
487 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { | 517 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { |
488 | int rc1 = 0; | 518 | int rc1 = 0; |
489 | __u64 inode_num; | ||
490 | 519 | ||
491 | rc1 = CIFSGetSrvInodeNumber(xid, pTcon, | 520 | rc1 = CIFSGetSrvInodeNumber(xid, pTcon, |
492 | full_path, &inode_num, | 521 | full_path, pinum, |
493 | cifs_sb->local_nls, | 522 | cifs_sb->local_nls, |
494 | cifs_sb->mnt_cifs_flags & | 523 | cifs_sb->mnt_cifs_flags & |
495 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 524 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
496 | if (rc1) { | 525 | if (rc1) { |
497 | cFYI(1, ("GetSrvInodeNum rc %d", rc1)); | 526 | cFYI(1, ("GetSrvInodeNum rc %d", rc1)); |
527 | pinum = NULL; | ||
498 | /* BB EOPNOSUPP disable SERVER_INUM? */ | 528 | /* BB EOPNOSUPP disable SERVER_INUM? */ |
499 | } else /* do we need cast or hash to ino? */ | 529 | } |
500 | (*pinode)->i_ino = inode_num; | 530 | } else { |
501 | } /* else ino incremented to unique num in new_inode*/ | 531 | pinum = NULL; |
502 | if (sb->s_flags & MS_NOATIME) | 532 | } |
503 | (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME; | 533 | |
504 | insert_inode_hash(*pinode); | 534 | *pinode = cifs_new_inode(sb, pinum); |
535 | if (*pinode == NULL) { | ||
536 | rc = -ENOMEM; | ||
537 | goto cgii_exit; | ||
538 | } | ||
505 | } | 539 | } |
506 | inode = *pinode; | 540 | inode = *pinode; |
507 | cifsInfo = CIFS_I(inode); | 541 | cifsInfo = CIFS_I(inode); |
@@ -621,7 +655,7 @@ static const struct inode_operations cifs_ipc_inode_ops = { | |||
621 | .lookup = cifs_lookup, | 655 | .lookup = cifs_lookup, |
622 | }; | 656 | }; |
623 | 657 | ||
624 | static char *build_path_to_root(struct cifs_sb_info *cifs_sb) | 658 | char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb) |
625 | { | 659 | { |
626 | int pplen = cifs_sb->prepathlen; | 660 | int pplen = cifs_sb->prepathlen; |
627 | int dfsplen; | 661 | int dfsplen; |
@@ -678,7 +712,7 @@ struct inode *cifs_iget(struct super_block *sb, unsigned long ino) | |||
678 | return inode; | 712 | return inode; |
679 | 713 | ||
680 | cifs_sb = CIFS_SB(inode->i_sb); | 714 | cifs_sb = CIFS_SB(inode->i_sb); |
681 | full_path = build_path_to_root(cifs_sb); | 715 | full_path = cifs_build_path_to_root(cifs_sb); |
682 | if (full_path == NULL) | 716 | if (full_path == NULL) |
683 | return ERR_PTR(-ENOMEM); | 717 | return ERR_PTR(-ENOMEM); |
684 | 718 | ||
@@ -1017,7 +1051,7 @@ out_reval: | |||
1017 | return rc; | 1051 | return rc; |
1018 | } | 1052 | } |
1019 | 1053 | ||
1020 | static void posix_fill_in_inode(struct inode *tmp_inode, | 1054 | void posix_fill_in_inode(struct inode *tmp_inode, |
1021 | FILE_UNIX_BASIC_INFO *pData, int isNewInode) | 1055 | FILE_UNIX_BASIC_INFO *pData, int isNewInode) |
1022 | { | 1056 | { |
1023 | struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode); | 1057 | struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode); |
@@ -1114,24 +1148,14 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
1114 | else | 1148 | else |
1115 | direntry->d_op = &cifs_dentry_ops; | 1149 | direntry->d_op = &cifs_dentry_ops; |
1116 | 1150 | ||
1117 | newinode = new_inode(inode->i_sb); | 1151 | newinode = cifs_new_inode(inode->i_sb, |
1152 | &pInfo->UniqueId); | ||
1118 | if (newinode == NULL) { | 1153 | if (newinode == NULL) { |
1119 | kfree(pInfo); | 1154 | kfree(pInfo); |
1120 | goto mkdir_get_info; | 1155 | goto mkdir_get_info; |
1121 | } | 1156 | } |
1122 | 1157 | ||
1123 | /* Is an i_ino of zero legal? */ | ||
1124 | /* Are there sanity checks we can use to ensure that | ||
1125 | the server is really filling in that field? */ | ||
1126 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { | ||
1127 | newinode->i_ino = | ||
1128 | (unsigned long)pInfo->UniqueId; | ||
1129 | } /* note ino incremented to unique num in new_inode */ | ||
1130 | if (inode->i_sb->s_flags & MS_NOATIME) | ||
1131 | newinode->i_flags |= S_NOATIME | S_NOCMTIME; | ||
1132 | newinode->i_nlink = 2; | 1158 | newinode->i_nlink = 2; |
1133 | |||
1134 | insert_inode_hash(newinode); | ||
1135 | d_instantiate(direntry, newinode); | 1159 | d_instantiate(direntry, newinode); |
1136 | 1160 | ||
1137 | /* we already checked in POSIXCreate whether | 1161 | /* we already checked in POSIXCreate whether |