Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ceph: check inode type for CEPH_CAP_FILE_{CACHE,RD,REXTEND,LAZYIO}

These bits will have new meaning for directory inodes.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

authored by

Yan, Zheng and committed by
Ilya Dryomov
525d15e8 f85122af

+35 -24
+32 -12
fs/ceph/caps.c
··· 573 573 * Each time we receive FILE_CACHE anew, we increment 574 574 * i_rdcache_gen. 575 575 */ 576 - if ((issued & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) && 576 + if (S_ISREG(ci->vfs_inode.i_mode) && 577 + (issued & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) && 577 578 (had & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0) { 578 579 ci->i_rdcache_gen++; 579 580 } ··· 959 958 if (ci->i_rd_ref) 960 959 used |= CEPH_CAP_FILE_RD; 961 960 if (ci->i_rdcache_ref || 962 - (!S_ISDIR(ci->vfs_inode.i_mode) && /* ignore readdir cache */ 961 + (S_ISREG(ci->vfs_inode.i_mode) && 963 962 ci->vfs_inode.i_data.nrpages)) 964 963 used |= CEPH_CAP_FILE_CACHE; 965 964 if (ci->i_wr_ref) ··· 984 983 if (bits == 0) 985 984 return 0; 986 985 return ceph_caps_for_mode(bits >> 1); 986 + } 987 + 988 + /* 989 + * wanted, by virtue of open file modes AND cap refs (buffered/cached data) 990 + */ 991 + int __ceph_caps_wanted(struct ceph_inode_info *ci) 992 + { 993 + int w = __ceph_caps_file_wanted(ci) | __ceph_caps_used(ci); 994 + if (!S_ISDIR(ci->vfs_inode.i_mode)) { 995 + /* we want EXCL if dirty data */ 996 + if (w & CEPH_CAP_FILE_BUFFER) 997 + w |= CEPH_CAP_FILE_EXCL; 998 + } 999 + return w; 987 1000 } 988 1001 989 1002 /* ··· 1918 1903 * If we fail, it's because pages are locked.... try again later. 1919 1904 */ 1920 1905 if ((!no_delay || mdsc->stopping) && 1921 - !S_ISDIR(inode->i_mode) && /* ignore readdir cache */ 1906 + S_ISREG(inode->i_mode) && 1922 1907 !(ci->i_wb_ref || ci->i_wrbuffer_ref) && /* no dirty pages... */ 1923 1908 inode->i_data.nrpages && /* have cached pages */ 1924 1909 (revoking & (CEPH_CAP_FILE_CACHE| ··· 2650 2635 snap_rwsem_locked = true; 2651 2636 } 2652 2637 *got = need | (have & want); 2653 - if ((need & CEPH_CAP_FILE_RD) && 2638 + if (S_ISREG(inode->i_mode) && 2639 + (need & CEPH_CAP_FILE_RD) && 2654 2640 !(*got & CEPH_CAP_FILE_CACHE)) 2655 2641 ceph_disable_fscache_readpage(ci); 2656 2642 __take_cap_refs(ci, *got, true); ··· 2659 2643 } 2660 2644 } else { 2661 2645 int session_readonly = false; 2662 - if ((need & CEPH_CAP_FILE_WR) && ci->i_auth_cap) { 2646 + if (ci->i_auth_cap && 2647 + (need & (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_EXCL))) { 2663 2648 struct ceph_mds_session *s = ci->i_auth_cap->session; 2664 2649 spin_lock(&s->s_cap_lock); 2665 2650 session_readonly = s->s_readonly; ··· 2834 2817 return ret; 2835 2818 } 2836 2819 2837 - if (ci->i_inline_version != CEPH_INLINE_NONE && 2820 + if (S_ISREG(ci->vfs_inode.i_mode) && 2821 + ci->i_inline_version != CEPH_INLINE_NONE && 2838 2822 (_got & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) && 2839 2823 i_size_read(inode) > 0) { 2840 2824 struct page *page = ··· 2868 2850 break; 2869 2851 } 2870 2852 2871 - if ((_got & CEPH_CAP_FILE_RD) && (_got & CEPH_CAP_FILE_CACHE)) 2853 + if (S_ISREG(ci->vfs_inode.i_mode) && 2854 + (_got & CEPH_CAP_FILE_RD) && (_got & CEPH_CAP_FILE_CACHE)) 2872 2855 ceph_fscache_revalidate_cookie(ci); 2873 2856 2874 2857 *got = _got; ··· 3159 3140 * try to invalidate (once). (If there are dirty buffers, we 3160 3141 * will invalidate _after_ writeback.) 3161 3142 */ 3162 - if (!S_ISDIR(inode->i_mode) && /* don't invalidate readdir cache */ 3143 + if (S_ISREG(inode->i_mode) && /* don't invalidate readdir cache */ 3163 3144 ((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) && 3164 3145 (newcaps & CEPH_CAP_FILE_LAZYIO) == 0 && 3165 3146 !(ci->i_wrbuffer_ref || ci->i_wb_ref)) { ··· 3323 3304 ceph_cap_string(cap->issued), 3324 3305 ceph_cap_string(newcaps), 3325 3306 ceph_cap_string(revoking)); 3326 - if (revoking & used & CEPH_CAP_FILE_BUFFER) 3307 + if (S_ISREG(inode->i_mode) && 3308 + (revoking & used & CEPH_CAP_FILE_BUFFER)) 3327 3309 writeback = true; /* initiate writeback; will delay ack */ 3328 - else if (revoking == CEPH_CAP_FILE_CACHE && 3329 - (newcaps & CEPH_CAP_FILE_LAZYIO) == 0 && 3330 - queue_invalidate) 3310 + else if (queue_invalidate && 3311 + revoking == CEPH_CAP_FILE_CACHE && 3312 + (newcaps & CEPH_CAP_FILE_LAZYIO) == 0) 3331 3313 ; /* do nothing yet, invalidation will be queued */ 3332 3314 else if (cap == ci->i_auth_cap) 3333 3315 check_caps = 1; /* check auth cap only */
+2 -1
fs/ceph/mds_client.c
··· 1776 1776 } 1777 1777 /* The inode has cached pages, but it's no longer used. 1778 1778 * we can safely drop it */ 1779 - if (wanted == 0 && used == CEPH_CAP_FILE_CACHE && 1779 + if (S_ISREG(inode->i_mode) && 1780 + wanted == 0 && used == CEPH_CAP_FILE_CACHE && 1780 1781 !(oissued & CEPH_CAP_FILE_CACHE)) { 1781 1782 used = 0; 1782 1783 oissued = 0;
+1 -11
fs/ceph/super.h
··· 675 675 extern int __ceph_caps_used(struct ceph_inode_info *ci); 676 676 677 677 extern int __ceph_caps_file_wanted(struct ceph_inode_info *ci); 678 - 679 - /* 680 - * wanted, by virtue of open file modes AND cap refs (buffered/cached data) 681 - */ 682 - static inline int __ceph_caps_wanted(struct ceph_inode_info *ci) 683 - { 684 - int w = __ceph_caps_file_wanted(ci) | __ceph_caps_used(ci); 685 - if (w & CEPH_CAP_FILE_BUFFER) 686 - w |= CEPH_CAP_FILE_EXCL; /* we want EXCL if dirty data */ 687 - return w; 688 - } 678 + extern int __ceph_caps_wanted(struct ceph_inode_info *ci); 689 679 690 680 /* what the mds thinks we want */ 691 681 extern int __ceph_caps_mds_wanted(struct ceph_inode_info *ci, bool check);