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()
589 struct gfs2_inode *ip = GFS2_I(d_inode(dentry)); in gfs2_xattr_get() local
593 if (!ip->i_eattr) in gfs2_xattr_get()
598 error = gfs2_ea_find(ip, type, name, &el); in gfs2_xattr_get()
604 error = gfs2_ea_get_copy(ip, &el, buffer, size); in gfs2_xattr_get()
620 static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp) in ea_alloc_blk() argument
622 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_alloc_blk()
628 error = gfs2_alloc_blocks(ip, &block, &n, 0, NULL); in ea_alloc_blk()
632 *bhp = gfs2_meta_new(ip->i_gl, block); in ea_alloc_blk()
633 gfs2_trans_add_meta(ip->i_gl, *bhp); in ea_alloc_blk()
643 gfs2_add_inode_blocks(&ip->i_inode, 1); in ea_alloc_blk()
660 static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea, in ea_write() argument
663 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_write()
690 error = gfs2_alloc_blocks(ip, &block, &n, 0, NULL); in ea_write()
694 bh = gfs2_meta_new(ip->i_gl, block); in ea_write()
695 gfs2_trans_add_meta(ip->i_gl, bh); in ea_write()
698 gfs2_add_inode_blocks(&ip->i_inode, 1); in ea_write()
720 typedef int (*ea_skeleton_call_t) (struct gfs2_inode *ip,
723 static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er, in ea_alloc_skeleton() argument
731 error = gfs2_rindex_update(GFS2_SB(&ip->i_inode)); in ea_alloc_skeleton()
735 error = gfs2_quota_lock_check(ip, &ap); in ea_alloc_skeleton()
739 error = gfs2_inplace_reserve(ip, &ap); in ea_alloc_skeleton()
743 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), in ea_alloc_skeleton()
744 blks + gfs2_rg_blocks(ip, blks) + in ea_alloc_skeleton()
749 error = skeleton_call(ip, er, private); in ea_alloc_skeleton()
753 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_alloc_skeleton()
755 ip->i_inode.i_ctime = CURRENT_TIME; in ea_alloc_skeleton()
756 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_alloc_skeleton()
757 gfs2_dinode_out(ip, dibh->b_data); in ea_alloc_skeleton()
762 gfs2_trans_end(GFS2_SB(&ip->i_inode)); in ea_alloc_skeleton()
764 gfs2_inplace_release(ip); in ea_alloc_skeleton()
766 gfs2_quota_unlock(ip); in ea_alloc_skeleton()
770 static int ea_init_i(struct gfs2_inode *ip, struct gfs2_ea_request *er, in ea_init_i() argument
776 error = ea_alloc_blk(ip, &bh); in ea_init_i()
780 ip->i_eattr = bh->b_blocknr; in ea_init_i()
781 error = ea_write(ip, GFS2_EA_BH2FIRST(bh), er); in ea_init_i()
796 static int ea_init(struct gfs2_inode *ip, int type, const char *name, in ea_init() argument
800 unsigned int jbsize = GFS2_SB(&ip->i_inode)->sd_jbsize; in ea_init()
812 return ea_alloc_skeleton(ip, &er, blks, ea_init_i, NULL); in ea_init()
832 static void ea_set_remove_stuffed(struct gfs2_inode *ip, in ea_set_remove_stuffed() argument
839 gfs2_trans_add_meta(ip->i_gl, el->el_bh); in ea_set_remove_stuffed()
846 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), GFS2_EA2NEXT(prev) == ea); in ea_set_remove_stuffed()
866 static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh, in ea_set_simple_noalloc() argument
873 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + 2 * RES_EATTR, 0); in ea_set_simple_noalloc()
877 gfs2_trans_add_meta(ip->i_gl, bh); in ea_set_simple_noalloc()
882 ea_write(ip, ea, er); in ea_set_simple_noalloc()
885 ea_set_remove_stuffed(ip, es->es_el); in ea_set_simple_noalloc()
887 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_set_simple_noalloc()
890 ip->i_inode.i_ctime = CURRENT_TIME; in ea_set_simple_noalloc()
891 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_set_simple_noalloc()
892 gfs2_dinode_out(ip, dibh->b_data); in ea_set_simple_noalloc()
895 gfs2_trans_end(GFS2_SB(&ip->i_inode)); in ea_set_simple_noalloc()
899 static int ea_set_simple_alloc(struct gfs2_inode *ip, in ea_set_simple_alloc() argument
906 gfs2_trans_add_meta(ip->i_gl, es->es_bh); in ea_set_simple_alloc()
911 error = ea_write(ip, ea, er); in ea_set_simple_alloc()
916 ea_set_remove_stuffed(ip, es->es_el); in ea_set_simple_alloc()
921 static int ea_set_simple(struct gfs2_inode *ip, struct buffer_head *bh, in ea_set_simple() argument
930 stuffed = ea_calc_size(GFS2_SB(&ip->i_inode), es->es_er->er_name_len, in ea_set_simple()
937 error = ea_remove_unstuffed(ip, bh, ea, prev, 1); in ea_set_simple()
948 error = ea_set_simple_noalloc(ip, bh, ea, es); in ea_set_simple()
957 GFS2_SB(&ip->i_inode)->sd_jbsize); in ea_set_simple()
959 error = ea_alloc_skeleton(ip, es->es_er, blks, in ea_set_simple()
968 static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er, in ea_set_block() argument
971 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_set_block()
977 if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) { in ea_set_block()
980 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, in ea_set_block()
1002 gfs2_trans_add_meta(ip->i_gl, indbh); in ea_set_block()
1006 error = gfs2_alloc_blocks(ip, &blk, &n, 0, NULL); in ea_set_block()
1010 indbh = gfs2_meta_new(ip->i_gl, blk); in ea_set_block()
1011 gfs2_trans_add_meta(ip->i_gl, indbh); in ea_set_block()
1016 *eablk = cpu_to_be64(ip->i_eattr); in ea_set_block()
1017 ip->i_eattr = blk; in ea_set_block()
1018 ip->i_diskflags |= GFS2_DIF_EA_INDIRECT; in ea_set_block()
1019 gfs2_add_inode_blocks(&ip->i_inode, 1); in ea_set_block()
1024 error = ea_alloc_blk(ip, &newbh); in ea_set_block()
1029 error = ea_write(ip, GFS2_EA_BH2FIRST(newbh), er); in ea_set_block()
1035 ea_set_remove_stuffed(ip, private); in ea_set_block()
1042 static int ea_set_i(struct gfs2_inode *ip, int type, const char *name, in ea_set_i() argument
1060 error = ea_foreach(ip, ea_set_simple, &es); in ea_set_i()
1066 if (!(ip->i_diskflags & GFS2_DIF_EA_INDIRECT)) in ea_set_i()
1068 if (GFS2_EAREQ_SIZE_STUFFED(&er) > GFS2_SB(&ip->i_inode)->sd_jbsize) in ea_set_i()
1069 blks += DIV_ROUND_UP(er.er_data_len, GFS2_SB(&ip->i_inode)->sd_jbsize); in ea_set_i()
1071 return ea_alloc_skeleton(ip, &er, blks, ea_set_block, el); in ea_set_i()
1074 static int ea_set_remove_unstuffed(struct gfs2_inode *ip, in ea_set_remove_unstuffed() argument
1079 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), in ea_set_remove_unstuffed()
1083 return ea_remove_unstuffed(ip, el->el_bh, el->el_ea, el->el_prev, 0); in ea_set_remove_unstuffed()
1086 static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el) in ea_remove_stuffed() argument
1093 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + RES_EATTR, 0); in ea_remove_stuffed()
1097 gfs2_trans_add_meta(ip->i_gl, el->el_bh); in ea_remove_stuffed()
1111 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_remove_stuffed()
1113 ip->i_inode.i_ctime = CURRENT_TIME; in ea_remove_stuffed()
1114 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_remove_stuffed()
1115 gfs2_dinode_out(ip, dibh->b_data); in ea_remove_stuffed()
1119 gfs2_trans_end(GFS2_SB(&ip->i_inode)); in ea_remove_stuffed()
1137 static int gfs2_xattr_remove(struct gfs2_inode *ip, int type, const char *name) in gfs2_xattr_remove() argument
1142 if (!ip->i_eattr) in gfs2_xattr_remove()
1145 error = gfs2_ea_find(ip, type, name, &el); in gfs2_xattr_remove()
1152 error = ea_remove_stuffed(ip, &el); in gfs2_xattr_remove()
1154 error = ea_remove_unstuffed(ip, el.el_bh, el.el_ea, el.el_prev, 0); in gfs2_xattr_remove()
1178 struct gfs2_inode *ip = GFS2_I(inode); in __gfs2_xattr_set() local
1190 return gfs2_xattr_remove(ip, type, name); in __gfs2_xattr_set()
1195 if (!ip->i_eattr) { in __gfs2_xattr_set()
1198 return ea_init(ip, type, name, value, size); in __gfs2_xattr_set()
1201 error = gfs2_ea_find(ip, type, name, &el); in __gfs2_xattr_set()
1206 if (ip->i_diskflags & GFS2_DIF_APPENDONLY) { in __gfs2_xattr_set()
1214 error = ea_set_i(ip, type, name, value, size, &el); in __gfs2_xattr_set()
1216 ea_set_remove_unstuffed(ip, &el); in __gfs2_xattr_set()
1225 error = ea_set_i(ip, type, name, value, size, NULL); in __gfs2_xattr_set()
1238 static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip, in ea_acl_chmod_unstuffed() argument
1241 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_acl_chmod_unstuffed()
1250 ret = gfs2_iter_unstuffed(ip, ea, data, NULL); in ea_acl_chmod_unstuffed()
1256 int gfs2_xattr_acl_chmod(struct gfs2_inode *ip, struct iattr *attr, char *data) in gfs2_xattr_acl_chmod() argument
1258 struct inode *inode = &ip->i_inode; in gfs2_xattr_acl_chmod()
1263 error = gfs2_ea_find(ip, GFS2_EATYPE_SYS, GFS2_POSIX_ACL_ACCESS, &el); in gfs2_xattr_acl_chmod()
1270 gfs2_trans_add_meta(ip->i_gl, el.el_bh); in gfs2_xattr_acl_chmod()
1275 error = ea_acl_chmod_unstuffed(ip, el.el_ea, data); in gfs2_xattr_acl_chmod()
1287 static int ea_dealloc_indirect(struct gfs2_inode *ip) in ea_dealloc_indirect() argument
1289 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_dealloc_indirect()
1306 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, &indbh); in ea_dealloc_indirect()
1329 gfs2_rlist_add(ip, &rlist, bstart); in ea_dealloc_indirect()
1336 gfs2_rlist_add(ip, &rlist, bstart); in ea_dealloc_indirect()
1357 gfs2_trans_add_meta(ip->i_gl, indbh); in ea_dealloc_indirect()
1374 gfs2_free_meta(ip, bstart, blen); in ea_dealloc_indirect()
1380 gfs2_add_inode_blocks(&ip->i_inode, -1); in ea_dealloc_indirect()
1383 gfs2_free_meta(ip, bstart, blen); in ea_dealloc_indirect()
1385 ip->i_diskflags &= ~GFS2_DIF_EA_INDIRECT; in ea_dealloc_indirect()
1387 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_dealloc_indirect()
1389 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_dealloc_indirect()
1390 gfs2_dinode_out(ip, dibh->b_data); in ea_dealloc_indirect()
1405 static int ea_dealloc_block(struct gfs2_inode *ip) in ea_dealloc_block() argument
1407 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_dealloc_block()
1417 rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr, 1); in ea_dealloc_block()
1419 gfs2_consist_inode(ip); in ea_dealloc_block()
1432 gfs2_free_meta(ip, ip->i_eattr, 1); in ea_dealloc_block()
1434 ip->i_eattr = 0; in ea_dealloc_block()
1435 gfs2_add_inode_blocks(&ip->i_inode, -1); in ea_dealloc_block()
1437 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_dealloc_block()
1439 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_dealloc_block()
1440 gfs2_dinode_out(ip, dibh->b_data); in ea_dealloc_block()
1458 int gfs2_ea_dealloc(struct gfs2_inode *ip) in gfs2_ea_dealloc() argument
1462 error = gfs2_rindex_update(GFS2_SB(&ip->i_inode)); in gfs2_ea_dealloc()
1466 error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE); in gfs2_ea_dealloc()
1470 error = ea_foreach(ip, ea_dealloc_unstuffed, NULL); in gfs2_ea_dealloc()
1474 if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) { in gfs2_ea_dealloc()
1475 error = ea_dealloc_indirect(ip); in gfs2_ea_dealloc()
1480 error = ea_dealloc_block(ip); in gfs2_ea_dealloc()
1483 gfs2_quota_unhold(ip); in gfs2_ea_dealloc()