• Home
  • Raw
  • Download

Lines Matching full:sbi

277 	struct hmdfs_sb_info *sbi = hmdfs_sb(sb);  in hmdfs_put_super()  local
278 struct super_block *lower_sb = sbi->lower_sb; in hmdfs_put_super()
280 hmdfs_info("local_dst is %s, local_src is %s", sbi->local_dst, in hmdfs_put_super()
281 sbi->local_src); in hmdfs_put_super()
283 hmdfs_cfn_destroy(sbi); in hmdfs_put_super()
284 hmdfs_unregister_sysfs(sbi); in hmdfs_put_super()
285 hmdfs_connections_stop(sbi); in hmdfs_put_super()
286 hmdfs_clear_share_table(sbi); in hmdfs_put_super()
287 hmdfs_destroy_server_writeback(sbi); in hmdfs_put_super()
288 hmdfs_exit_stash(sbi); in hmdfs_put_super()
290 put_cred(sbi->cred); in hmdfs_put_super()
291 if (sbi->system_cred) in hmdfs_put_super()
292 put_cred(sbi->system_cred); in hmdfs_put_super()
293 hmdfs_destroy_writeback(sbi); in hmdfs_put_super()
294 kfree(sbi->local_src); in hmdfs_put_super()
295 kfree(sbi->local_dst); in hmdfs_put_super()
296 kfree(sbi->real_dst); in hmdfs_put_super()
297 kfree(sbi->cache_dir); in hmdfs_put_super()
298 kfree(sbi->cloud_dir); in hmdfs_put_super()
299 kfifo_free(&sbi->notify_fifo); in hmdfs_put_super()
301 sbi->lower_sb = NULL; in hmdfs_put_super()
302 hmdfs_release_sysfs(sbi); in hmdfs_put_super()
304 hmdfs_free_sb_seq(sbi->seq); in hmdfs_put_super()
305 kfree(sbi->s_server_statis); in hmdfs_put_super()
306 kfree(sbi->s_client_statis); in hmdfs_put_super()
307 kfree(sbi); in hmdfs_put_super()
338 struct hmdfs_sb_info *sbi = hmdfs_sb(dentry->d_inode->i_sb); in hmdfs_remote_statfs() local
351 mutex_lock(&sbi->connections.node_lock); in hmdfs_remote_statfs()
352 list_for_each_entry(con, &sbi->connections.node_list, list) { in hmdfs_remote_statfs()
355 mutex_unlock(&sbi->connections.node_lock); in hmdfs_remote_statfs()
362 mutex_lock(&sbi->connections.node_lock); in hmdfs_remote_statfs()
365 mutex_unlock(&sbi->connections.node_lock); in hmdfs_remote_statfs()
379 struct hmdfs_sb_info *sbi = sb->s_fs_info; in hmdfs_statfs() local
385 err = kern_path(sbi->local_src, 0, &lower_path); in hmdfs_statfs()
405 struct hmdfs_sb_info *sbi = hmdfs_sb(root->d_sb); in hmdfs_show_options() local
407 if (sbi->s_case_sensitive) in hmdfs_show_options()
412 if (sbi->s_merge_switch) in hmdfs_show_options()
418 seq_printf(m, ",user_id=%u", sbi->user_id); in hmdfs_show_options()
420 if (sbi->cache_dir) in hmdfs_show_options()
421 seq_printf(m, ",cache_dir=%s", sbi->cache_dir); in hmdfs_show_options()
422 if (sbi->real_dst) in hmdfs_show_options()
423 seq_printf(m, ",real_dst=%s", sbi->real_dst); in hmdfs_show_options()
424 if (sbi->cloud_dir) in hmdfs_show_options()
425 seq_printf(m, ",cloud_dir=%s", sbi->cloud_dir); in hmdfs_show_options()
427 seq_printf(m, ",%soffline_stash", sbi->s_offline_stash ? "" : "no_"); in hmdfs_show_options()
428 seq_printf(m, ",%sdentry_cache", sbi->s_dentry_cache ? "" : "no_"); in hmdfs_show_options()
438 struct hmdfs_sb_info *sbi = hmdfs_sb(sb); in hmdfs_sync_fs() local
439 int syncfs_timeout = get_cmd_timeout(sbi, F_SYNCFS); in hmdfs_sync_fs()
445 trace_hmdfs_syncfs_enter(sbi); in hmdfs_sync_fs()
447 spin_lock(&sbi->hsi.list_lock); in hmdfs_sync_fs()
448 if (!sbi->hsi.is_executing) { in hmdfs_sync_fs()
449 sbi->hsi.is_executing = true; in hmdfs_sync_fs()
451 spin_unlock(&sbi->hsi.list_lock); in hmdfs_sync_fs()
454 list_add_tail(&item.list, &sbi->hsi.wait_list); in hmdfs_sync_fs()
455 spin_unlock(&sbi->hsi.list_lock); in hmdfs_sync_fs()
465 * during the waiting period we must protect @sbi->remote_syncfs_count in hmdfs_sync_fs()
466 * and @sbi->remote_syncfs_ret from concurrent executing. in hmdfs_sync_fs()
469 spin_lock(&sbi->hsi.v_lock); in hmdfs_sync_fs()
470 sbi->hsi.version++; in hmdfs_sync_fs()
472 * Attention: We put @sbi->hsi.remote_ret and @sbi->hsi.wait_count in hmdfs_sync_fs()
477 * sbi->hsi.remote_ret = 0; in hmdfs_sync_fs()
478 * atomic_set(&sbi->hsi.wait_count, 0); in hmdfs_sync_fs()
481 * sbi->hsi.remote_ret = resp->ret_code in hmdfs_sync_fs()
482 * atomic_dec(&sbi->hsi.wait_count); in hmdfs_sync_fs()
488 * @sbi->hsi.remote_ret and @sbi->hsi.wait_count can be assigned in hmdfs_sync_fs()
492 sbi->hsi.remote_ret = 0; in hmdfs_sync_fs()
493 atomic_set(&sbi->hsi.wait_count, 0); in hmdfs_sync_fs()
494 spin_unlock(&sbi->hsi.v_lock); in hmdfs_sync_fs()
496 mutex_lock(&sbi->connections.node_lock); in hmdfs_sync_fs()
497 list_for_each_entry(con, &sbi->connections.node_list, list) { in hmdfs_sync_fs()
507 mutex_unlock(&sbi->connections.node_lock); in hmdfs_sync_fs()
522 mutex_lock(&sbi->connections.node_lock); in hmdfs_sync_fs()
530 sbi->hsi.remote_ret = err; in hmdfs_sync_fs()
532 mutex_lock(&sbi->connections.node_lock); in hmdfs_sync_fs()
536 atomic_inc(&sbi->hsi.wait_count); in hmdfs_sync_fs()
539 mutex_lock(&sbi->connections.node_lock); in hmdfs_sync_fs()
541 mutex_unlock(&sbi->connections.node_lock); in hmdfs_sync_fs()
544 * Async work in background will make sure @sbi->remote_syncfs_count in hmdfs_sync_fs()
548 sbi->hsi.wq, atomic_read(&sbi->hsi.wait_count) == 0); in hmdfs_sync_fs()
554 if (!err && sbi->hsi.remote_ret) in hmdfs_sync_fs()
555 err = sbi->hsi.remote_ret; in hmdfs_sync_fs()
558 list_for_each_entry_safe(entry, tmp, &sbi->hsi.pending_list, list) { in hmdfs_sync_fs()
562 INIT_LIST_HEAD(&sbi->hsi.pending_list); in hmdfs_sync_fs()
565 spin_lock(&sbi->hsi.list_lock); in hmdfs_sync_fs()
566 if (list_empty(&sbi->hsi.wait_list)) { in hmdfs_sync_fs()
567 sbi->hsi.is_executing = false; in hmdfs_sync_fs()
569 entry = list_last_entry(&sbi->hsi.wait_list, struct syncfs_item, in hmdfs_sync_fs()
572 list_splice_init(&sbi->hsi.wait_list, &sbi->hsi.pending_list); in hmdfs_sync_fs()
576 spin_unlock(&sbi->hsi.list_lock); in hmdfs_sync_fs()
579 trace_hmdfs_syncfs_exit(sbi, atomic_read(&sbi->hsi.wait_count), in hmdfs_sync_fs()
580 get_cmd_timeout(sbi, F_SYNCFS), err); in hmdfs_sync_fs()
682 static void hmdfs_init_cmd_timeout(struct hmdfs_sb_info *sbi) in hmdfs_init_cmd_timeout() argument
684 memset(sbi->s_cmd_timeout, 0xff, sizeof(sbi->s_cmd_timeout)); in hmdfs_init_cmd_timeout()
686 set_cmd_timeout(sbi, F_OPEN, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
687 set_cmd_timeout(sbi, F_RELEASE, TIMEOUT_NONE); in hmdfs_init_cmd_timeout()
688 set_cmd_timeout(sbi, F_READPAGE, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
689 set_cmd_timeout(sbi, F_WRITEPAGE, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
690 set_cmd_timeout(sbi, F_ITERATE, TIMEOUT_30S); in hmdfs_init_cmd_timeout()
691 set_cmd_timeout(sbi, F_CREATE, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
692 set_cmd_timeout(sbi, F_MKDIR, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
693 set_cmd_timeout(sbi, F_RMDIR, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
694 set_cmd_timeout(sbi, F_UNLINK, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
695 set_cmd_timeout(sbi, F_RENAME, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
696 set_cmd_timeout(sbi, F_SETATTR, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
697 set_cmd_timeout(sbi, F_STATFS, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
698 set_cmd_timeout(sbi, F_CONNECT_REKEY, TIMEOUT_NONE); in hmdfs_init_cmd_timeout()
699 set_cmd_timeout(sbi, F_DROP_PUSH, TIMEOUT_NONE); in hmdfs_init_cmd_timeout()
700 set_cmd_timeout(sbi, F_GETATTR, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
701 set_cmd_timeout(sbi, F_FSYNC, TIMEOUT_90S); in hmdfs_init_cmd_timeout()
702 set_cmd_timeout(sbi, F_SYNCFS, TIMEOUT_30S); in hmdfs_init_cmd_timeout()
703 set_cmd_timeout(sbi, F_GETXATTR, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
704 set_cmd_timeout(sbi, F_SETXATTR, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
705 set_cmd_timeout(sbi, F_LISTXATTR, TIMEOUT_COMMON); in hmdfs_init_cmd_timeout()
708 static int hmdfs_init_sbi(struct hmdfs_sb_info *sbi) in hmdfs_init_sbi() argument
712 ret = kfifo_alloc(&sbi->notify_fifo, PAGE_SIZE, GFP_KERNEL); in hmdfs_init_sbi()
720 sbi->s_server_statis = in hmdfs_init_sbi()
721 kzalloc(sizeof(*sbi->s_server_statis) * F_SIZE, GFP_KERNEL); in hmdfs_init_sbi()
722 sbi->s_client_statis = in hmdfs_init_sbi()
723 kzalloc(sizeof(*sbi->s_client_statis) * F_SIZE, GFP_KERNEL); in hmdfs_init_sbi()
724 if (!sbi->s_server_statis || !sbi->s_client_statis) { in hmdfs_init_sbi()
734 sbi->seq = ret; in hmdfs_init_sbi()
737 spin_lock_init(&sbi->notify_fifo_lock); in hmdfs_init_sbi()
738 mutex_init(&sbi->cmd_handler_mutex); in hmdfs_init_sbi()
739 sbi->s_case_sensitive = false; in hmdfs_init_sbi()
740 sbi->s_features = HMDFS_FEATURE_READPAGES | in hmdfs_init_sbi()
743 sbi->s_merge_switch = false; in hmdfs_init_sbi()
744 sbi->s_cloud_disk_switch = false; in hmdfs_init_sbi()
745 sbi->dcache_threshold = DEFAULT_DCACHE_THRESHOLD; in hmdfs_init_sbi()
746 sbi->dcache_precision = DEFAULT_DCACHE_PRECISION; in hmdfs_init_sbi()
747 sbi->dcache_timeout = DEFAULT_DCACHE_TIMEOUT; in hmdfs_init_sbi()
748 sbi->write_cache_timeout = DEFAULT_WRITE_CACHE_TIMEOUT; in hmdfs_init_sbi()
749 hmdfs_init_cmd_timeout(sbi); in hmdfs_init_sbi()
750 sbi->async_cb_delay = HMDFS_NODE_EVT_CB_DELAY; in hmdfs_init_sbi()
751 sbi->async_req_max_active = DEFAULT_SRV_REQ_MAX_ACTIVE; in hmdfs_init_sbi()
752 sbi->s_offline_stash = true; in hmdfs_init_sbi()
753 sbi->s_dentry_cache = true; in hmdfs_init_sbi()
754 sbi->wb_timeout_ms = HMDFS_DEF_WB_TIMEOUT_MS; in hmdfs_init_sbi()
755 sbi->s_readpages_nr = HMDFS_READPAGES_NR_DEF; in hmdfs_init_sbi()
757 atomic_set(&sbi->connections.conn_seq, 0); in hmdfs_init_sbi()
758 mutex_init(&sbi->connections.node_lock); in hmdfs_init_sbi()
759 INIT_LIST_HEAD(&sbi->connections.node_list); in hmdfs_init_sbi()
761 ret = hmdfs_init_share_table(sbi); in hmdfs_init_sbi()
764 init_waitqueue_head(&sbi->async_readdir_wq); in hmdfs_init_sbi()
765 INIT_LIST_HEAD(&sbi->async_readdir_msg_list); in hmdfs_init_sbi()
766 INIT_LIST_HEAD(&sbi->async_readdir_work_list); in hmdfs_init_sbi()
767 spin_lock_init(&sbi->async_readdir_msg_lock); in hmdfs_init_sbi()
768 spin_lock_init(&sbi->async_readdir_work_lock); in hmdfs_init_sbi()
776 void hmdfs_client_resp_statis(struct hmdfs_sb_info *sbi, u8 cmd, in hmdfs_client_resp_statis() argument
784 sbi->s_client_statis[cmd].delay_resp_cnt++; in hmdfs_client_resp_statis()
787 sbi->s_client_statis[cmd].timeout_cnt++; in hmdfs_client_resp_statis()
791 sbi->s_client_statis[cmd].total += duration; in hmdfs_client_resp_statis()
792 sbi->s_client_statis[cmd].resp_cnt++; in hmdfs_client_resp_statis()
793 if (sbi->s_client_statis[cmd].max < duration) in hmdfs_client_resp_statis()
794 sbi->s_client_statis[cmd].max = duration; in hmdfs_client_resp_statis()
801 static int hmdfs_update_dst(struct hmdfs_sb_info *sbi) in hmdfs_update_dst() argument
807 sbi->real_dst = kstrdup(sbi->local_dst, GFP_KERNEL); in hmdfs_update_dst()
808 if (!sbi->real_dst) { in hmdfs_update_dst()
812 kfree(sbi->local_dst); in hmdfs_update_dst()
813 sbi->local_dst = NULL; in hmdfs_update_dst()
815 len = strlen(sbi->real_dst) + strlen(path_local) + 1; in hmdfs_update_dst()
820 sbi->local_dst = kmalloc(len, GFP_KERNEL); in hmdfs_update_dst()
821 if (!sbi->local_dst) { in hmdfs_update_dst()
825 snprintf(sbi->local_dst, strlen(sbi->real_dst) + strlen(path_local) + 1, in hmdfs_update_dst()
826 "%s%s", sbi->real_dst, path_local); in hmdfs_update_dst()
861 struct hmdfs_sb_info *sbi; in hmdfs_fill_super() local
873 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); in hmdfs_fill_super()
874 if (!sbi) { in hmdfs_fill_super()
878 err = hmdfs_init_sbi(sbi); in hmdfs_fill_super()
881 sbi->sb = sb; in hmdfs_fill_super()
882 err = hmdfs_parse_options(sbi, raw_data); in hmdfs_fill_super()
886 sb->s_fs_info = sbi; in hmdfs_fill_super()
891 sbi->boot_cookie = hmdfs_gen_boot_cookie(); in hmdfs_fill_super()
893 err = hmdfs_init_writeback(sbi); in hmdfs_fill_super()
896 err = hmdfs_init_server_writeback(sbi); in hmdfs_fill_super()
900 err = hmdfs_init_stash(sbi); in hmdfs_fill_super()
905 ctrl_hash = path_hash(sbi->local_dst, strlen(sbi->local_dst), true); in hmdfs_fill_super()
908 err = hmdfs_register_sysfs(ctrl_path, sbi); in hmdfs_fill_super()
912 err = hmdfs_update_dst(sbi); in hmdfs_fill_super()
925 sbi->lower_sb = lower_sb; in hmdfs_fill_super()
926 sbi->local_src = get_full_path(&lower_path); in hmdfs_fill_super()
927 if (!sbi->local_src) { in hmdfs_fill_super()
940 root_inode = fill_root_inode(sb, sbi, d_inode(lower_path.dentry)); in hmdfs_fill_super()
951 if (sbi->s_cloud_disk_switch) in hmdfs_fill_super()
952 err = init_hmdfs_dentry_info(sbi, root_dentry, HMDFS_LAYER_SECOND_LOCAL); in hmdfs_fill_super()
954 err = init_hmdfs_dentry_info(sbi, root_dentry, HMDFS_LAYER_ZERO); in hmdfs_fill_super()
958 sbi->cred = get_cred(current_cred()); in hmdfs_fill_super()
959 INIT_LIST_HEAD(&sbi->client_cache); in hmdfs_fill_super()
960 INIT_LIST_HEAD(&sbi->server_cache); in hmdfs_fill_super()
961 INIT_LIST_HEAD(&sbi->to_delete); in hmdfs_fill_super()
962 mutex_init(&sbi->cache_list_lock); in hmdfs_fill_super()
963 hmdfs_cfn_load(sbi); in hmdfs_fill_super()
966 spin_lock_init(&sbi->hsi.v_lock); in hmdfs_fill_super()
967 init_waitqueue_head(&sbi->hsi.wq); in hmdfs_fill_super()
968 sbi->hsi.version = 0; in hmdfs_fill_super()
969 sbi->hsi.is_executing = false; in hmdfs_fill_super()
970 INIT_LIST_HEAD(&sbi->hsi.wait_list); in hmdfs_fill_super()
971 INIT_LIST_HEAD(&sbi->hsi.pending_list); in hmdfs_fill_super()
972 spin_lock_init(&sbi->hsi.list_lock); in hmdfs_fill_super()
982 hmdfs_unregister_sysfs(sbi); in hmdfs_fill_super()
983 hmdfs_release_sysfs(sbi); in hmdfs_fill_super()
985 if (sbi) { in hmdfs_fill_super()
987 hmdfs_clear_share_table(sbi); in hmdfs_fill_super()
988 hmdfs_exit_stash(sbi); in hmdfs_fill_super()
989 hmdfs_destroy_writeback(sbi); in hmdfs_fill_super()
990 hmdfs_destroy_server_writeback(sbi); in hmdfs_fill_super()
991 kfifo_free(&sbi->notify_fifo); in hmdfs_fill_super()
992 hmdfs_free_sb_seq(sbi->seq); in hmdfs_fill_super()
993 kfree(sbi->local_src); in hmdfs_fill_super()
994 kfree(sbi->local_dst); in hmdfs_fill_super()
995 kfree(sbi->real_dst); in hmdfs_fill_super()
996 kfree(sbi->cache_dir); in hmdfs_fill_super()
997 kfree(sbi->cloud_dir); in hmdfs_fill_super()
998 kfree(sbi->s_server_statis); in hmdfs_fill_super()
999 kfree(sbi->s_client_statis); in hmdfs_fill_super()
1000 kfree(sbi); in hmdfs_fill_super()
1021 static void hmdfs_cancel_async_readdir(struct hmdfs_sb_info *sbi) in hmdfs_cancel_async_readdir() argument
1031 spin_lock(&sbi->async_readdir_work_lock); in hmdfs_cancel_async_readdir()
1032 list_for_each_entry_safe(rw, tmp, &sbi->async_readdir_work_list, head) { in hmdfs_cancel_async_readdir()
1036 spin_unlock(&sbi->async_readdir_work_lock); in hmdfs_cancel_async_readdir()
1045 spin_lock(&sbi->async_readdir_msg_lock); in hmdfs_cancel_async_readdir()
1046 sbi->async_readdir_prohibit = true; in hmdfs_cancel_async_readdir()
1047 list_for_each_entry(msg_wq, &sbi->async_readdir_msg_list, async_msg) in hmdfs_cancel_async_readdir()
1049 spin_unlock(&sbi->async_readdir_msg_lock); in hmdfs_cancel_async_readdir()
1052 if (!list_empty(&sbi->async_readdir_work_list)) in hmdfs_cancel_async_readdir()
1053 wait_event_interruptible_timeout(sbi->async_readdir_wq, in hmdfs_cancel_async_readdir()
1054 (list_empty(&sbi->async_readdir_work_list)), HZ); in hmdfs_cancel_async_readdir()
1056 WARN_ON(!(list_empty(&sbi->async_readdir_work_list))); in hmdfs_cancel_async_readdir()
1061 struct hmdfs_sb_info *sbi = hmdfs_sb(sb); in hmdfs_kill_super() local
1068 if (sbi) in hmdfs_kill_super()
1069 hmdfs_cancel_async_readdir(sbi); in hmdfs_kill_super()