Lines Matching refs:ip

75 typedef int (*ea_call_t) (struct gfs2_inode *ip, struct buffer_head *bh,
79 static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh, in ea_foreach_i() argument
85 if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), bh, GFS2_METATYPE_EA)) in ea_foreach_i()
97 error = ea_call(ip, bh, ea, prev, data); in ea_foreach_i()
112 gfs2_consist_inode(ip); in ea_foreach_i()
116 static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data) in ea_foreach() argument
122 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, &bh); in ea_foreach()
126 if (!(ip->i_diskflags & GFS2_DIF_EA_INDIRECT)) { in ea_foreach()
127 error = ea_foreach_i(ip, bh, ea_call, data); in ea_foreach()
131 if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), bh, GFS2_METATYPE_IN)) { in ea_foreach()
137 end = eablk + GFS2_SB(&ip->i_inode)->sd_inptrs; in ea_foreach()
146 error = gfs2_meta_read(ip->i_gl, bn, DIO_WAIT, &eabh); in ea_foreach()
149 error = ea_foreach_i(ip, eabh, ea_call, data); in ea_foreach()
166 static int ea_find_i(struct gfs2_inode *ip, struct buffer_head *bh, in ea_find_i() argument
190 static int gfs2_ea_find(struct gfs2_inode *ip, int type, const char *name, in gfs2_ea_find() argument
203 error = ea_foreach(ip, ea_find_i, &ef); in gfs2_ea_find()
225 static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, in ea_dealloc_unstuffed() argument
230 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_dealloc_unstuffed()
261 gfs2_consist_inode(ip); in ea_dealloc_unstuffed()
274 gfs2_trans_add_meta(ip->i_gl, bh); in ea_dealloc_unstuffed()
286 gfs2_free_meta(ip, bstart, blen); in ea_dealloc_unstuffed()
292 gfs2_add_inode_blocks(&ip->i_inode, -1); in ea_dealloc_unstuffed()
295 gfs2_free_meta(ip, bstart, blen); in ea_dealloc_unstuffed()
310 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_dealloc_unstuffed()
312 ip->i_inode.i_ctime = CURRENT_TIME; in ea_dealloc_unstuffed()
313 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_dealloc_unstuffed()
314 gfs2_dinode_out(ip, dibh->b_data); in ea_dealloc_unstuffed()
325 static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, in ea_remove_unstuffed() argument
331 error = gfs2_rindex_update(GFS2_SB(&ip->i_inode)); in ea_remove_unstuffed()
335 error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE); in ea_remove_unstuffed()
339 error = ea_dealloc_unstuffed(ip, bh, ea, prev, (leave) ? &error : NULL); in ea_remove_unstuffed()
341 gfs2_quota_unhold(ip); in ea_remove_unstuffed()
365 static int ea_list_i(struct gfs2_inode *ip, struct buffer_head *bh, in ea_list_i() argument
423 struct gfs2_inode *ip = GFS2_I(d_inode(dentry)); in gfs2_listxattr() local
434 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh); in gfs2_listxattr()
438 if (ip->i_eattr) { in gfs2_listxattr()
441 error = ea_foreach(ip, ea_list_i, &ei); in gfs2_listxattr()
462 static int gfs2_iter_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea, in gfs2_iter_unstuffed() argument
465 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_iter_unstuffed()
480 error = gfs2_meta_read(ip->i_gl, be64_to_cpu(*dataptrs), 0, in gfs2_iter_unstuffed()
513 gfs2_trans_add_meta(ip->i_gl, bh[x]); in gfs2_iter_unstuffed()
527 static int gfs2_ea_get_copy(struct gfs2_inode *ip, struct gfs2_ea_location *el, in gfs2_ea_get_copy() argument
539 ret = gfs2_iter_unstuffed(ip, el->el_ea, NULL, data); in gfs2_ea_get_copy()
545 int gfs2_xattr_acl_get(struct gfs2_inode *ip, const char *name, char **ppdata) in gfs2_xattr_acl_get() argument
552 error = gfs2_ea_find(ip, GFS2_EATYPE_SYS, name, &el); in gfs2_xattr_acl_get()
566 error = gfs2_ea_get_copy(ip, &el, data, len); in gfs2_xattr_acl_get()
590 struct gfs2_inode *ip = GFS2_I(d_inode(dentry)); in gfs2_xattr_get() local
595 if (!ip->i_eattr) in gfs2_xattr_get()
600 error = gfs2_ea_find(ip, type, name, &el); in gfs2_xattr_get()
606 error = gfs2_ea_get_copy(ip, &el, buffer, size); in gfs2_xattr_get()
622 static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp) in ea_alloc_blk() argument
624 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_alloc_blk()
630 error = gfs2_alloc_blocks(ip, &block, &n, 0, NULL); in ea_alloc_blk()
634 *bhp = gfs2_meta_new(ip->i_gl, block); in ea_alloc_blk()
635 gfs2_trans_add_meta(ip->i_gl, *bhp); in ea_alloc_blk()
645 gfs2_add_inode_blocks(&ip->i_inode, 1); in ea_alloc_blk()
662 static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea, in ea_write() argument
665 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_write()
692 error = gfs2_alloc_blocks(ip, &block, &n, 0, NULL); in ea_write()
696 bh = gfs2_meta_new(ip->i_gl, block); in ea_write()
697 gfs2_trans_add_meta(ip->i_gl, bh); in ea_write()
700 gfs2_add_inode_blocks(&ip->i_inode, 1); in ea_write()
722 typedef int (*ea_skeleton_call_t) (struct gfs2_inode *ip,
725 static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er, in ea_alloc_skeleton() argument
733 error = gfs2_rindex_update(GFS2_SB(&ip->i_inode)); in ea_alloc_skeleton()
737 error = gfs2_quota_lock_check(ip, &ap); in ea_alloc_skeleton()
741 error = gfs2_inplace_reserve(ip, &ap); in ea_alloc_skeleton()
745 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), in ea_alloc_skeleton()
746 blks + gfs2_rg_blocks(ip, blks) + in ea_alloc_skeleton()
751 error = skeleton_call(ip, er, private); in ea_alloc_skeleton()
755 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_alloc_skeleton()
757 ip->i_inode.i_ctime = CURRENT_TIME; in ea_alloc_skeleton()
758 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_alloc_skeleton()
759 gfs2_dinode_out(ip, dibh->b_data); in ea_alloc_skeleton()
764 gfs2_trans_end(GFS2_SB(&ip->i_inode)); in ea_alloc_skeleton()
766 gfs2_inplace_release(ip); in ea_alloc_skeleton()
768 gfs2_quota_unlock(ip); in ea_alloc_skeleton()
772 static int ea_init_i(struct gfs2_inode *ip, struct gfs2_ea_request *er, in ea_init_i() argument
778 error = ea_alloc_blk(ip, &bh); in ea_init_i()
782 ip->i_eattr = bh->b_blocknr; in ea_init_i()
783 error = ea_write(ip, GFS2_EA_BH2FIRST(bh), er); in ea_init_i()
798 static int ea_init(struct gfs2_inode *ip, int type, const char *name, in ea_init() argument
802 unsigned int jbsize = GFS2_SB(&ip->i_inode)->sd_jbsize; in ea_init()
814 return ea_alloc_skeleton(ip, &er, blks, ea_init_i, NULL); in ea_init()
834 static void ea_set_remove_stuffed(struct gfs2_inode *ip, in ea_set_remove_stuffed() argument
841 gfs2_trans_add_meta(ip->i_gl, el->el_bh); in ea_set_remove_stuffed()
848 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), GFS2_EA2NEXT(prev) == ea); in ea_set_remove_stuffed()
868 static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh, in ea_set_simple_noalloc() argument
875 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + 2 * RES_EATTR, 0); in ea_set_simple_noalloc()
879 gfs2_trans_add_meta(ip->i_gl, bh); in ea_set_simple_noalloc()
884 ea_write(ip, ea, er); in ea_set_simple_noalloc()
887 ea_set_remove_stuffed(ip, es->es_el); in ea_set_simple_noalloc()
889 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_set_simple_noalloc()
892 ip->i_inode.i_ctime = CURRENT_TIME; in ea_set_simple_noalloc()
893 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_set_simple_noalloc()
894 gfs2_dinode_out(ip, dibh->b_data); in ea_set_simple_noalloc()
897 gfs2_trans_end(GFS2_SB(&ip->i_inode)); in ea_set_simple_noalloc()
901 static int ea_set_simple_alloc(struct gfs2_inode *ip, in ea_set_simple_alloc() argument
908 gfs2_trans_add_meta(ip->i_gl, es->es_bh); in ea_set_simple_alloc()
913 error = ea_write(ip, ea, er); in ea_set_simple_alloc()
918 ea_set_remove_stuffed(ip, es->es_el); in ea_set_simple_alloc()
923 static int ea_set_simple(struct gfs2_inode *ip, struct buffer_head *bh, in ea_set_simple() argument
932 stuffed = ea_calc_size(GFS2_SB(&ip->i_inode), es->es_er->er_name_len, in ea_set_simple()
939 error = ea_remove_unstuffed(ip, bh, ea, prev, 1); in ea_set_simple()
950 error = ea_set_simple_noalloc(ip, bh, ea, es); in ea_set_simple()
959 GFS2_SB(&ip->i_inode)->sd_jbsize); in ea_set_simple()
961 error = ea_alloc_skeleton(ip, es->es_er, blks, in ea_set_simple()
970 static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er, in ea_set_block() argument
973 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_set_block()
979 if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) { in ea_set_block()
982 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, in ea_set_block()
1004 gfs2_trans_add_meta(ip->i_gl, indbh); in ea_set_block()
1008 error = gfs2_alloc_blocks(ip, &blk, &n, 0, NULL); in ea_set_block()
1012 indbh = gfs2_meta_new(ip->i_gl, blk); in ea_set_block()
1013 gfs2_trans_add_meta(ip->i_gl, indbh); in ea_set_block()
1018 *eablk = cpu_to_be64(ip->i_eattr); in ea_set_block()
1019 ip->i_eattr = blk; in ea_set_block()
1020 ip->i_diskflags |= GFS2_DIF_EA_INDIRECT; in ea_set_block()
1021 gfs2_add_inode_blocks(&ip->i_inode, 1); in ea_set_block()
1026 error = ea_alloc_blk(ip, &newbh); in ea_set_block()
1031 error = ea_write(ip, GFS2_EA_BH2FIRST(newbh), er); in ea_set_block()
1037 ea_set_remove_stuffed(ip, private); in ea_set_block()
1044 static int ea_set_i(struct gfs2_inode *ip, int type, const char *name, in ea_set_i() argument
1062 error = ea_foreach(ip, ea_set_simple, &es); in ea_set_i()
1068 if (!(ip->i_diskflags & GFS2_DIF_EA_INDIRECT)) in ea_set_i()
1070 if (GFS2_EAREQ_SIZE_STUFFED(&er) > GFS2_SB(&ip->i_inode)->sd_jbsize) in ea_set_i()
1071 blks += DIV_ROUND_UP(er.er_data_len, GFS2_SB(&ip->i_inode)->sd_jbsize); in ea_set_i()
1073 return ea_alloc_skeleton(ip, &er, blks, ea_set_block, el); in ea_set_i()
1076 static int ea_set_remove_unstuffed(struct gfs2_inode *ip, in ea_set_remove_unstuffed() argument
1081 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), in ea_set_remove_unstuffed()
1085 return ea_remove_unstuffed(ip, el->el_bh, el->el_ea, el->el_prev, 0); in ea_set_remove_unstuffed()
1088 static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el) in ea_remove_stuffed() argument
1095 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + RES_EATTR, 0); in ea_remove_stuffed()
1099 gfs2_trans_add_meta(ip->i_gl, el->el_bh); in ea_remove_stuffed()
1113 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_remove_stuffed()
1115 ip->i_inode.i_ctime = CURRENT_TIME; in ea_remove_stuffed()
1116 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_remove_stuffed()
1117 gfs2_dinode_out(ip, dibh->b_data); in ea_remove_stuffed()
1121 gfs2_trans_end(GFS2_SB(&ip->i_inode)); in ea_remove_stuffed()
1139 static int gfs2_xattr_remove(struct gfs2_inode *ip, int type, const char *name) in gfs2_xattr_remove() argument
1144 if (!ip->i_eattr) in gfs2_xattr_remove()
1147 error = gfs2_ea_find(ip, type, name, &el); in gfs2_xattr_remove()
1154 error = ea_remove_stuffed(ip, &el); in gfs2_xattr_remove()
1156 error = ea_remove_unstuffed(ip, el.el_bh, el.el_ea, el.el_prev, 0); in gfs2_xattr_remove()
1180 struct gfs2_inode *ip = GFS2_I(inode); in __gfs2_xattr_set() local
1192 return gfs2_xattr_remove(ip, type, name); in __gfs2_xattr_set()
1197 if (!ip->i_eattr) { in __gfs2_xattr_set()
1200 return ea_init(ip, type, name, value, size); in __gfs2_xattr_set()
1203 error = gfs2_ea_find(ip, type, name, &el); in __gfs2_xattr_set()
1208 if (ip->i_diskflags & GFS2_DIF_APPENDONLY) { in __gfs2_xattr_set()
1216 error = ea_set_i(ip, type, name, value, size, &el); in __gfs2_xattr_set()
1218 ea_set_remove_unstuffed(ip, &el); in __gfs2_xattr_set()
1227 error = ea_set_i(ip, type, name, value, size, NULL); in __gfs2_xattr_set()
1241 static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip, in ea_acl_chmod_unstuffed() argument
1244 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_acl_chmod_unstuffed()
1253 ret = gfs2_iter_unstuffed(ip, ea, data, NULL); in ea_acl_chmod_unstuffed()
1259 int gfs2_xattr_acl_chmod(struct gfs2_inode *ip, struct iattr *attr, char *data) in gfs2_xattr_acl_chmod() argument
1261 struct inode *inode = &ip->i_inode; in gfs2_xattr_acl_chmod()
1266 error = gfs2_ea_find(ip, GFS2_EATYPE_SYS, GFS2_POSIX_ACL_ACCESS, &el); in gfs2_xattr_acl_chmod()
1273 gfs2_trans_add_meta(ip->i_gl, el.el_bh); in gfs2_xattr_acl_chmod()
1278 error = ea_acl_chmod_unstuffed(ip, el.el_ea, data); in gfs2_xattr_acl_chmod()
1290 static int ea_dealloc_indirect(struct gfs2_inode *ip) in ea_dealloc_indirect() argument
1292 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_dealloc_indirect()
1309 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, &indbh); in ea_dealloc_indirect()
1332 gfs2_rlist_add(ip, &rlist, bstart); in ea_dealloc_indirect()
1339 gfs2_rlist_add(ip, &rlist, bstart); in ea_dealloc_indirect()
1360 gfs2_trans_add_meta(ip->i_gl, indbh); in ea_dealloc_indirect()
1377 gfs2_free_meta(ip, bstart, blen); in ea_dealloc_indirect()
1383 gfs2_add_inode_blocks(&ip->i_inode, -1); in ea_dealloc_indirect()
1386 gfs2_free_meta(ip, bstart, blen); in ea_dealloc_indirect()
1388 ip->i_diskflags &= ~GFS2_DIF_EA_INDIRECT; in ea_dealloc_indirect()
1390 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_dealloc_indirect()
1392 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_dealloc_indirect()
1393 gfs2_dinode_out(ip, dibh->b_data); in ea_dealloc_indirect()
1408 static int ea_dealloc_block(struct gfs2_inode *ip) in ea_dealloc_block() argument
1410 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_dealloc_block()
1420 rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr, 1); in ea_dealloc_block()
1422 gfs2_consist_inode(ip); in ea_dealloc_block()
1435 gfs2_free_meta(ip, ip->i_eattr, 1); in ea_dealloc_block()
1437 ip->i_eattr = 0; in ea_dealloc_block()
1438 gfs2_add_inode_blocks(&ip->i_inode, -1); in ea_dealloc_block()
1440 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_dealloc_block()
1442 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_dealloc_block()
1443 gfs2_dinode_out(ip, dibh->b_data); in ea_dealloc_block()
1461 int gfs2_ea_dealloc(struct gfs2_inode *ip) in gfs2_ea_dealloc() argument
1465 error = gfs2_rindex_update(GFS2_SB(&ip->i_inode)); in gfs2_ea_dealloc()
1469 error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE); in gfs2_ea_dealloc()
1473 error = ea_foreach(ip, ea_dealloc_unstuffed, NULL); in gfs2_ea_dealloc()
1477 if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) { in gfs2_ea_dealloc()
1478 error = ea_dealloc_indirect(ip); in gfs2_ea_dealloc()
1483 error = ea_dealloc_block(ip); in gfs2_ea_dealloc()
1486 gfs2_quota_unhold(ip); in gfs2_ea_dealloc()