Lines Matching refs:info
28 struct hmdfs_inode_info *info)
30 return time_after(jiffies, info->writecache_expire);
47 * @info: hmdfs inode info
51 static int hmdfs_open_final_remote(struct hmdfs_inode_info *info,
55 struct inode *inode = &info->vfs_inode;
64 if (info->remote_ino != open_ret->ino) {
67 info->remote_ino, open_ret->ino);
68 hmdfs_send_close(info->conn, &open_ret->fid);
76 trace_hmdfs_open_final_remote(info, open_ret, file, reason);
85 hmdfs_time_compare(&info->remote_ctime, &open_ret->remote_ctime)) {
95 if (info->writecache_expire) {
96 truncate = hmdfs_remote_write_cache_expired(info);
105 if (info->stable_ctime.tv_sec == 0 && info->stable_ctime.tv_nsec == 0) {
125 if (hmdfs_time_compare(&info->stable_ctime, &open_ret->stable_ctime)) {
132 trace_hmdfs_open_final_remote(info, open_ret, file, reason);
138 info->remote_ctime = open_ret->remote_ctime;
142 info->writecache_expire = 0;
146 atomic64_set(&info->write_counter, 0);
147 info->stable_ctime = open_ret->stable_ctime;
149 info->getattr_isize = HMDFS_STALE_REMOTE_ISIZE;
151 spin_lock(&info->fid_lock);
152 info->fid = open_ret->fid;
153 spin_unlock(&info->fid_lock);
159 struct hmdfs_inode_info *info = hmdfs_i(file_inode(file));
160 struct hmdfs_peer *conn = info->conn;
177 err = hmdfs_open_final_remote(info, &open_ret, file, keep_cache);
184 static inline bool hmdfs_remote_need_reopen(struct hmdfs_inode_info *info)
186 return test_bit(HMDFS_FID_NEED_OPEN, &info->fid_flags);
189 static inline bool hmdfs_remote_is_opening_file(struct hmdfs_inode_info *info)
191 return test_bit(HMDFS_FID_OPENING, &info->fid_flags);
194 static int hmdfs_remote_wait_opening_file(struct hmdfs_inode_info *info)
198 if (!hmdfs_remote_is_opening_file(info))
201 err = ___wait_event(info->fid_wq, hmdfs_remote_is_opening_file(info),
203 spin_unlock(&info->fid_lock);
205 spin_lock(&info->fid_lock));
212 static int hmdfs_remote_file_reopen(struct hmdfs_inode_info *info,
216 struct hmdfs_peer *conn = info->conn;
223 spin_lock(&info->fid_lock);
224 err = hmdfs_remote_wait_opening_file(info);
225 if (err || !hmdfs_remote_need_reopen(info)) {
226 spin_unlock(&info->fid_lock);
230 set_bit(HMDFS_FID_OPENING, &info->fid_flags);
231 fid = info->fid;
232 spin_unlock(&info->fid_lock);
234 inode = &info->vfs_inode;
253 spin_lock(&info->fid_lock);
262 clear_bit(HMDFS_FID_NEED_OPEN, &info->fid_flags);
263 clear_bit(HMDFS_FID_OPENING, &info->fid_flags);
264 spin_unlock(&info->fid_lock);
266 wake_up_interruptible_all(&info->fid_wq);
271 static int hmdfs_remote_check_and_reopen(struct hmdfs_inode_info *info,
274 if (!hmdfs_remote_need_reopen(info))
277 return hmdfs_remote_file_reopen(info, filp);
282 struct hmdfs_inode_info *info =
286 hmdfs_remote_fetch_fid(info, &fid);
288 hmdfs_send_close(info->conn, &fid);
298 hmdfs_remote_del_wr_opened_inode_nolock(struct hmdfs_inode_info *info)
300 WARN_ON(list_empty(&info->wr_opened_node));
301 if (atomic_dec_and_test(&info->wr_opened_cnt))
302 list_del_init(&info->wr_opened_node);
306 struct hmdfs_inode_info *info)
309 hmdfs_remote_del_wr_opened_inode_nolock(info);
314 struct hmdfs_inode_info *info)
316 if (list_empty(&info->wr_opened_node)) {
317 atomic_set(&info->wr_opened_cnt, 1);
318 list_add_tail(&info->wr_opened_node,
321 atomic_inc(&info->wr_opened_cnt);
326 struct hmdfs_inode_info *info)
329 hmdfs_remote_add_wr_opened_inode_nolock(conn, info);
335 struct hmdfs_inode_info *info = hmdfs_i(inode);
336 struct kref *ref = &(info->ref);
351 hmdfs_remote_add_wr_opened_inode(info->conn, info);
356 static void hmdfs_set_writecache_expire(struct hmdfs_inode_info *info,
366 if (info->writecache_expire &&
367 time_after(new_expire, info->writecache_expire))
370 info->writecache_expire = new_expire;
375 struct hmdfs_inode_info *info = NULL;
385 info = hmdfs_i(inode);
386 ref = &(info->ref);
391 if (kref_read(ref) > 0 || !atomic64_read(&info->write_counter))
398 err = hmdfs_remote_getattr(info->conn, file_dentry(file), 0,
416 info->remote_ctime = getattr_ret->stat.ctime;
417 hmdfs_set_writecache_expire(info, write_cache_timeout);
423 struct hmdfs_inode_info *info = hmdfs_i(inode);
426 hmdfs_remote_del_wr_opened_inode(info->conn, info);
429 kref_put(&info->ref, hmdfs_do_close_remote);
466 struct hmdfs_inode_info *info = hmdfs_i(file_inode(filp));
473 err = hmdfs_remote_check_and_reopen(info, filp);
479 rtt = hmdfs_tcpi_rtt(info->conn) / 10000;
495 if (err < 0 && !tried && hmdfs_remote_need_reopen(info)) {
504 static inline bool hmdfs_is_file_unwritable(const struct hmdfs_inode_info *info,
507 return (check_stash && hmdfs_inode_is_stashing(info)) ||
508 !hmdfs_is_node_online(info->conn);
517 struct hmdfs_inode_info *info = hmdfs_i(inode);
520 if (hmdfs_is_file_unwritable(info, check_stash))
523 ret = hmdfs_remote_check_and_reopen(info, filp);
528 if (hmdfs_is_file_unwritable(info, check_stash)) {
578 struct hmdfs_inode_info *info = hmdfs_i(file_inode(file));
579 struct hmdfs_peer *conn = info->conn;
584 info->remote_ino, datasync);
589 hmdfs_remote_check_and_reopen(info, file);
592 down_write(&info->wpage_sem);
594 up_write(&info->wpage_sem);
600 hmdfs_remote_fetch_fid(info, &fid);
607 info->remote_ino,
645 struct hmdfs_inode_info *info = hmdfs_i(inode);
660 hmdfs_remote_fetch_fid(info, &fid);
661 return hmdfs_client_readpage(info->conn, &fid, page);
697 static bool allow_cur_thread_wpage(struct hmdfs_inode_info *info,
706 *rsem_held = down_read_trylock(&info->wpage_sem);
726 struct hmdfs_inode_info *info = hmdfs_i(inode);
733 if (!allow_cur_thread_wpage(info, &rsem_held, sync))
752 hmdfs_remote_fetch_fid(info, ¶m->fid);
759 ret = hmdfs_remote_do_writepage(info->conn, param);
769 up_read(&info->wpage_sem);
771 if (sync || !hmdfs_need_redirty_page(info, ret)) {
1027 struct hmdfs_inode_info *info = hmdfs_i(inode);
1030 if (info->conn) {
1031 if (!hmdfs_cache_revalidate(READ_ONCE(info->conn->conn_time),
1032 info->conn->device_id,
1035 info->conn);
1036 cache_item = hmdfs_find_cache_item(info->conn->device_id,