diff --git a/fs/hmdfs/dentry.c b/fs/hmdfs/dentry.c index d12ef45f3071152c31a193587c9d722a02469cfe..040d698e17850bcb70ce65c816441ae6ae0f584f 100644 --- a/fs/hmdfs/dentry.c +++ b/fs/hmdfs/dentry.c @@ -289,6 +289,8 @@ static int d_revalidate_merge(struct dentry *direntry, unsigned int flags) struct hmdfs_dentry_comrade *comrade = NULL; struct dentry *parent_dentry = NULL; struct dentry *lower_cur_parent_dentry = NULL; + struct inode *dinode = NULL; + struct hmdfs_inode_info *info = NULL; int ret = 1; if (flags & LOOKUP_RCU) { @@ -299,6 +301,14 @@ static int d_revalidate_merge(struct dentry *direntry, unsigned int flags) return 0; } + dinode = d_inode(direntry); + if (!dinode) + return 0; + + info = hmdfs_i(dinode); + if (info->inode_type == HMDFS_LAYER_FIRST_MERGE_CLOUD) + return 1; + parent_dentry = dget_parent(direntry); mutex_lock(&dim->comrade_list_lock); list_for_each_entry(comrade, &(dim->comrade_list), list) { diff --git a/fs/hmdfs/file_cloud.c b/fs/hmdfs/file_cloud.c index df7ff9eb9d54a168a4379d25e0f5c715c4789111..0706b6653abf7f7034ceede7fd655010fdbf2ef1 100644 --- a/fs/hmdfs/file_cloud.c +++ b/fs/hmdfs/file_cloud.c @@ -35,7 +35,6 @@ static ssize_t hmdfs_file_read_iter_cloud(struct kiocb *iocb, struct iov_iter *iter) { ssize_t ret = -ENOENT; - const struct iovec *iov; struct file *filp = iocb->ki_filp; struct hmdfs_file_info *gfi = filp->private_data; struct file *lower_file = NULL; @@ -43,14 +42,10 @@ static ssize_t hmdfs_file_read_iter_cloud(struct kiocb *iocb, if (gfi) lower_file = gfi->lower_file; - if (uaccess_kernel()) - iov = (struct iovec *)iter->kvec; - else - iov = iter->iov; - - if (lower_file) - ret = vfs_read(lower_file, iov->iov_base, iov->iov_len, - &iocb->ki_pos); + if (lower_file) { + kiocb_clone(iocb, iocb, lower_file); + ret = vfs_iter_read(lower_file, iter, &iocb->ki_pos, 0); + } return ret; } diff --git a/fs/hmdfs/file_root.c b/fs/hmdfs/file_root.c index 73c026de04f9fcabaf7e0da2589162ca27e44843..02f331511da8f43cb47900e71553598da541e977 100644 --- a/fs/hmdfs/file_root.c +++ b/fs/hmdfs/file_root.c @@ -150,12 +150,14 @@ int hmdfs_root_iterate(struct file *file, struct dir_context *ctx) if (!dir_emit(ctx, MERGE_VIEW_ROOT, sizeof(MERGE_VIEW_ROOT) - 1, ino_start, DT_DIR)) return 0; + ino_start++; (ctx->pos)++; } if (sbi->s_merge_switch && ctx->pos == CLOUD_MERGE_VIEW_CTX_POS) { if (!dir_emit(ctx, CLOUD_MERGE_VIEW_ROOT, sizeof(CLOUD_MERGE_VIEW_ROOT) - 1, ino_start, DT_DIR)) return 0; + ino_start++; (ctx->pos)++; } return 0; diff --git a/fs/hmdfs/hmdfs_dentryfile.c b/fs/hmdfs/hmdfs_dentryfile.c index 0541308ffd0902c1819a237ffce52bb34d32e322..01efcba2f6cebe9bc44a4b67117903f19e2ef17d 100644 --- a/fs/hmdfs/hmdfs_dentryfile.c +++ b/fs/hmdfs/hmdfs_dentryfile.c @@ -294,7 +294,8 @@ static char *hmdfs_merge_dentry_path_raw(struct dentry *d, char *buf, int buflen retval = end - 1; *retval = '/'; read_seqbegin_or_lock(&rename_lock, &seq); - while (mdi->dentry_type != HMDFS_LAYER_FIRST_MERGE) { + while (mdi->dentry_type != HMDFS_LAYER_FIRST_MERGE && + mdi->dentry_type != HMDFS_LAYER_FIRST_MERGE_CLOUD) { struct dentry *parent = dentry->d_parent; prefetch(parent); diff --git a/fs/hmdfs/hmdfs_device_view.h b/fs/hmdfs/hmdfs_device_view.h index 2e306fe99de8cc03c8967a6b52dc8e13a8229298..5c525a9c7622905d3860f0ff5349c920e591c44e 100644 --- a/fs/hmdfs/hmdfs_device_view.h +++ b/fs/hmdfs/hmdfs_device_view.h @@ -246,7 +246,8 @@ static inline bool hmdfs_support_xattr(struct dentry *dentry) if (info->inode_type != HMDFS_LAYER_OTHER_LOCAL && info->inode_type != HMDFS_LAYER_OTHER_REMOTE && - info->inode_type != HMDFS_LAYER_OTHER_MERGE) + info->inode_type != HMDFS_LAYER_OTHER_MERGE && + info->inode_type != HMDFS_LAYER_OTHER_MERGE_CLOUD) return false; if (!S_ISREG(inode->i_mode)) diff --git a/fs/hmdfs/hmdfs_merge_view.h b/fs/hmdfs/hmdfs_merge_view.h index 1d7beae7147e4868a5b480fb934e7a901a45648f..aeda4127d1cc2d528445a48810a78e83b72fb732 100644 --- a/fs/hmdfs/hmdfs_merge_view.h +++ b/fs/hmdfs/hmdfs_merge_view.h @@ -227,7 +227,9 @@ static inline bool is_merge_lookup_end(struct hmdfs_dentry_info_merge *mdi) static inline bool hmdfs_i_merge(struct hmdfs_inode_info *hii) { __u8 t = hii->inode_type; - return t == HMDFS_LAYER_FIRST_MERGE || t == HMDFS_LAYER_OTHER_MERGE; + return t == HMDFS_LAYER_FIRST_MERGE || t == HMDFS_LAYER_OTHER_MERGE || + t == HMDFS_LAYER_FIRST_MERGE_CLOUD || + t == HMDFS_LAYER_OTHER_MERGE_CLOUD; } struct dentry *hmdfs_get_lo_d(struct dentry *dentry, int dev_id); diff --git a/fs/hmdfs/inode_cloud_merge.c b/fs/hmdfs/inode_cloud_merge.c index 1d1dc7ee39f54622bb2e2eb1d421a8be781d8bb6..07fbedb328828a06c23777470aa0cbe9c942b4ce 100644 --- a/fs/hmdfs/inode_cloud_merge.c +++ b/fs/hmdfs/inode_cloud_merge.c @@ -41,7 +41,7 @@ static struct inode *fill_inode_merge(struct super_block *sb, goto out; } if (hmdfs_i(parent_inode)->inode_type == HMDFS_LAYER_ZERO) - inode = hmdfs_iget_locked_root(sb, HMDFS_ROOT_MERGE, NULL, + inode = hmdfs_iget_locked_root(sb, HMDFS_ROOT_MERGE_CLOUD, NULL, NULL); else inode = hmdfs_iget5_locked_merge(sb, fst_lo_d); @@ -54,9 +54,9 @@ static struct inode *fill_inode_merge(struct super_block *sb, goto out; info = hmdfs_i(inode); if (hmdfs_i(parent_inode)->inode_type == HMDFS_LAYER_ZERO) - info->inode_type = HMDFS_LAYER_FIRST_MERGE; + info->inode_type = HMDFS_LAYER_FIRST_MERGE_CLOUD; else - info->inode_type = HMDFS_LAYER_OTHER_MERGE; + info->inode_type = HMDFS_LAYER_OTHER_MERGE_CLOUD; inode->i_uid = USER_DATA_RW_UID; inode->i_gid = USER_DATA_RW_GID; @@ -182,7 +182,7 @@ static int do_lookup_cloud_merge_root(struct path path_dev, buf[5] = '\0'; comrade = lookup_comrade(path_dev, buf, CLOUD_DEVICE, flags); if (IS_ERR(comrade)) { - ret = PTR_ERR(comrade); + ret = 0; goto out; } @@ -281,10 +281,10 @@ struct dentry *hmdfs_lookup_cloud_merge(struct inode *parent_inode, goto out; if (pii->inode_type == HMDFS_LAYER_ZERO) { - hmdfs_dm(child_dentry)->dentry_type = HMDFS_LAYER_FIRST_MERGE; + hmdfs_dm(child_dentry)->dentry_type = HMDFS_LAYER_FIRST_MERGE_CLOUD; err = lookup_cloud_merge_root(parent_inode, child_dentry, flags); } else { - hmdfs_dm(child_dentry)->dentry_type = HMDFS_LAYER_OTHER_MERGE; + hmdfs_dm(child_dentry)->dentry_type = HMDFS_LAYER_OTHER_MERGE_CLOUD; err = lookup_merge_normal(child_dentry, flags); } @@ -304,7 +304,7 @@ struct dentry *hmdfs_lookup_cloud_merge(struct inode *parent_inode, child_dentry = ret_dentry; } info = hmdfs_i(child_inode); - if (info->inode_type == HMDFS_LAYER_FIRST_MERGE) + if (info->inode_type == HMDFS_LAYER_FIRST_MERGE_CLOUD) hmdfs_root_inode_perm_init(child_inode); else check_and_fixup_ownership_remote(parent_inode, diff --git a/fs/hmdfs/main.c b/fs/hmdfs/main.c index b3bd822842554b119cff1d2830dfafd65dee9d9e..179ddfa7821824e0f9ce5bacc93976f603ce7321 100644 --- a/fs/hmdfs/main.c +++ b/fs/hmdfs/main.c @@ -197,7 +197,8 @@ static int hmdfs_xattr_set(const struct xattr_handler *handler, if (info->inode_type == HMDFS_LAYER_OTHER_LOCAL) return hmdfs_xattr_local_set(dentry, name, value, size, flags); - else if (info->inode_type == HMDFS_LAYER_OTHER_MERGE) + else if (info->inode_type == HMDFS_LAYER_OTHER_MERGE || + info->inode_type == HMDFS_LAYER_OTHER_MERGE_CLOUD) return hmdfs_xattr_merge_set(dentry, name, value, size, flags); return hmdfs_xattr_remote_set(dentry, name, value, size, flags);