Lines Matching full:ip
73 typedef int (*ea_call_t) (struct gfs2_inode *ip, struct buffer_head *bh,
77 static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh, in ea_foreach_i() argument
83 if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), bh, GFS2_METATYPE_EA)) in ea_foreach_i()
95 error = ea_call(ip, bh, ea, prev, data); in ea_foreach_i()
110 gfs2_consist_inode(ip); in ea_foreach_i()
114 static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data) in ea_foreach() argument
120 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, 0, &bh); in ea_foreach()
124 if (!(ip->i_diskflags & GFS2_DIF_EA_INDIRECT)) { in ea_foreach()
125 error = ea_foreach_i(ip, bh, ea_call, data); in ea_foreach()
129 if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), bh, GFS2_METATYPE_IN)) { in ea_foreach()
135 end = eablk + GFS2_SB(&ip->i_inode)->sd_inptrs; in ea_foreach()
144 error = gfs2_meta_read(ip->i_gl, bn, DIO_WAIT, 0, &eabh); in ea_foreach()
147 error = ea_foreach_i(ip, eabh, ea_call, data); in ea_foreach()
164 static int ea_find_i(struct gfs2_inode *ip, struct buffer_head *bh, in ea_find_i() argument
188 static int gfs2_ea_find(struct gfs2_inode *ip, int type, const char *name, in gfs2_ea_find() argument
201 error = ea_foreach(ip, ea_find_i, &ef); in gfs2_ea_find()
210 * @ip:
223 static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, in ea_dealloc_unstuffed() argument
228 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_dealloc_unstuffed()
258 gfs2_consist_inode(ip); in ea_dealloc_unstuffed()
271 gfs2_trans_add_meta(ip->i_gl, bh); in ea_dealloc_unstuffed()
283 gfs2_free_meta(ip, rgd, bstart, blen); in ea_dealloc_unstuffed()
289 gfs2_add_inode_blocks(&ip->i_inode, -1); in ea_dealloc_unstuffed()
292 gfs2_free_meta(ip, rgd, bstart, blen); in ea_dealloc_unstuffed()
307 ip->i_inode.i_ctime = current_time(&ip->i_inode); in ea_dealloc_unstuffed()
308 __mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC); in ea_dealloc_unstuffed()
317 static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, in ea_remove_unstuffed() argument
323 error = gfs2_rindex_update(GFS2_SB(&ip->i_inode)); in ea_remove_unstuffed()
327 error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE); in ea_remove_unstuffed()
331 error = ea_dealloc_unstuffed(ip, bh, ea, prev, (leave) ? &error : NULL); in ea_remove_unstuffed()
333 gfs2_quota_unhold(ip); in ea_remove_unstuffed()
343 static int ea_list_i(struct gfs2_inode *ip, struct buffer_head *bh, in ea_list_i() argument
400 struct gfs2_inode *ip = GFS2_I(d_inode(dentry)); in gfs2_listxattr() local
411 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh); in gfs2_listxattr()
415 if (ip->i_eattr) { in gfs2_listxattr()
418 error = ea_foreach(ip, ea_list_i, &ei); in gfs2_listxattr()
431 * @ip: The GFS2 inode
439 static int gfs2_iter_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea, in gfs2_iter_unstuffed() argument
442 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_iter_unstuffed()
457 error = gfs2_meta_read(ip->i_gl, be64_to_cpu(*dataptrs), 0, 0, in gfs2_iter_unstuffed()
490 gfs2_trans_add_meta(ip->i_gl, bh[x]); in gfs2_iter_unstuffed()
504 static int gfs2_ea_get_copy(struct gfs2_inode *ip, struct gfs2_ea_location *el, in gfs2_ea_get_copy() argument
516 ret = gfs2_iter_unstuffed(ip, el->el_ea, NULL, data); in gfs2_ea_get_copy()
522 int gfs2_xattr_acl_get(struct gfs2_inode *ip, const char *name, char **ppdata) in gfs2_xattr_acl_get() argument
529 error = gfs2_ea_find(ip, GFS2_EATYPE_SYS, name, &el); in gfs2_xattr_acl_get()
543 error = gfs2_ea_get_copy(ip, &el, data, len); in gfs2_xattr_acl_get()
566 struct gfs2_inode *ip = GFS2_I(inode); in __gfs2_xattr_get() local
570 if (!ip->i_eattr) in __gfs2_xattr_get()
575 error = gfs2_ea_find(ip, type, name, &el); in __gfs2_xattr_get()
581 error = gfs2_ea_get_copy(ip, &el, buffer, size); in __gfs2_xattr_get()
593 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_xattr_get() local
599 if (!gfs2_glock_is_locked_by_me(ip->i_gl)) { in gfs2_xattr_get()
600 ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); in gfs2_xattr_get()
614 * @ip: A pointer to the inode that's getting extended attributes
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()
651 * @ip: inode that is being modified
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
730 error = gfs2_rindex_update(GFS2_SB(&ip->i_inode)); in ea_alloc_skeleton()
734 error = gfs2_quota_lock_check(ip, &ap); in ea_alloc_skeleton()
738 error = gfs2_inplace_reserve(ip, &ap); in ea_alloc_skeleton()
742 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), in ea_alloc_skeleton()
743 blks + gfs2_rg_blocks(ip, blks) + in ea_alloc_skeleton()
748 error = skeleton_call(ip, er, private); in ea_alloc_skeleton()
752 ip->i_inode.i_ctime = current_time(&ip->i_inode); in ea_alloc_skeleton()
753 __mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC); in ea_alloc_skeleton()
756 gfs2_trans_end(GFS2_SB(&ip->i_inode)); in ea_alloc_skeleton()
758 gfs2_inplace_release(ip); in ea_alloc_skeleton()
760 gfs2_quota_unlock(ip); in ea_alloc_skeleton()
764 static int ea_init_i(struct gfs2_inode *ip, struct gfs2_ea_request *er, in ea_init_i() argument
770 error = ea_alloc_blk(ip, &bh); in ea_init_i()
774 ip->i_eattr = bh->b_blocknr; in ea_init_i()
775 error = ea_write(ip, GFS2_EA_BH2FIRST(bh), er); in ea_init_i()
784 * @ip:
790 static int ea_init(struct gfs2_inode *ip, int type, const char *name, in ea_init() argument
794 unsigned int jbsize = GFS2_SB(&ip->i_inode)->sd_jbsize; in ea_init()
806 return ea_alloc_skeleton(ip, &er, blks, ea_init_i, NULL); in ea_init()
826 static void ea_set_remove_stuffed(struct gfs2_inode *ip, in ea_set_remove_stuffed() argument
833 gfs2_trans_add_meta(ip->i_gl, el->el_bh); in ea_set_remove_stuffed()
840 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), GFS2_EA2NEXT(prev) == ea); in ea_set_remove_stuffed()
860 static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh, in ea_set_simple_noalloc() argument
866 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + 2 * RES_EATTR, 0); in ea_set_simple_noalloc()
870 gfs2_trans_add_meta(ip->i_gl, bh); in ea_set_simple_noalloc()
875 ea_write(ip, ea, er); in ea_set_simple_noalloc()
878 ea_set_remove_stuffed(ip, es->es_el); in ea_set_simple_noalloc()
880 ip->i_inode.i_ctime = current_time(&ip->i_inode); in ea_set_simple_noalloc()
881 __mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC); in ea_set_simple_noalloc()
883 gfs2_trans_end(GFS2_SB(&ip->i_inode)); in ea_set_simple_noalloc()
887 static int ea_set_simple_alloc(struct gfs2_inode *ip, in ea_set_simple_alloc() argument
894 gfs2_trans_add_meta(ip->i_gl, es->es_bh); in ea_set_simple_alloc()
899 error = ea_write(ip, ea, er); in ea_set_simple_alloc()
904 ea_set_remove_stuffed(ip, es->es_el); in ea_set_simple_alloc()
909 static int ea_set_simple(struct gfs2_inode *ip, struct buffer_head *bh, in ea_set_simple() argument
918 stuffed = ea_calc_size(GFS2_SB(&ip->i_inode), es->es_er->er_name_len, in ea_set_simple()
925 error = ea_remove_unstuffed(ip, bh, ea, prev, 1); in ea_set_simple()
936 error = ea_set_simple_noalloc(ip, bh, ea, es); in ea_set_simple()
945 GFS2_SB(&ip->i_inode)->sd_jbsize); in ea_set_simple()
947 error = ea_alloc_skeleton(ip, es->es_er, blks, in ea_set_simple()
956 static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er, in ea_set_block() argument
959 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_set_block()
965 if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) { in ea_set_block()
968 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, 0, in ea_set_block()
990 gfs2_trans_add_meta(ip->i_gl, indbh); in ea_set_block()
994 error = gfs2_alloc_blocks(ip, &blk, &n, 0, NULL); in ea_set_block()
998 indbh = gfs2_meta_new(ip->i_gl, blk); in ea_set_block()
999 gfs2_trans_add_meta(ip->i_gl, indbh); in ea_set_block()
1004 *eablk = cpu_to_be64(ip->i_eattr); in ea_set_block()
1005 ip->i_eattr = blk; in ea_set_block()
1006 ip->i_diskflags |= GFS2_DIF_EA_INDIRECT; in ea_set_block()
1007 gfs2_add_inode_blocks(&ip->i_inode, 1); in ea_set_block()
1012 error = ea_alloc_blk(ip, &newbh); in ea_set_block()
1017 error = ea_write(ip, GFS2_EA_BH2FIRST(newbh), er); in ea_set_block()
1023 ea_set_remove_stuffed(ip, private); in ea_set_block()
1030 static int ea_set_i(struct gfs2_inode *ip, int type, const char *name, in ea_set_i() argument
1048 error = ea_foreach(ip, ea_set_simple, &es); in ea_set_i()
1054 if (!(ip->i_diskflags & GFS2_DIF_EA_INDIRECT)) in ea_set_i()
1056 if (GFS2_EAREQ_SIZE_STUFFED(&er) > GFS2_SB(&ip->i_inode)->sd_jbsize) in ea_set_i()
1057 blks += DIV_ROUND_UP(er.er_data_len, GFS2_SB(&ip->i_inode)->sd_jbsize); in ea_set_i()
1059 return ea_alloc_skeleton(ip, &er, blks, ea_set_block, el); in ea_set_i()
1062 static int ea_set_remove_unstuffed(struct gfs2_inode *ip, in ea_set_remove_unstuffed() argument
1067 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), in ea_set_remove_unstuffed()
1071 return ea_remove_unstuffed(ip, el->el_bh, el->el_ea, el->el_prev, 0); in ea_set_remove_unstuffed()
1074 static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el) in ea_remove_stuffed() argument
1080 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + RES_EATTR, 0); in ea_remove_stuffed()
1084 gfs2_trans_add_meta(ip->i_gl, el->el_bh); in ea_remove_stuffed()
1098 ip->i_inode.i_ctime = current_time(&ip->i_inode); in ea_remove_stuffed()
1099 __mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC); in ea_remove_stuffed()
1101 gfs2_trans_end(GFS2_SB(&ip->i_inode)); in ea_remove_stuffed()
1108 * @ip: The inode
1119 static int gfs2_xattr_remove(struct gfs2_inode *ip, int type, const char *name) in gfs2_xattr_remove() argument
1124 if (!ip->i_eattr) in gfs2_xattr_remove()
1127 error = gfs2_ea_find(ip, type, name, &el); in gfs2_xattr_remove()
1134 error = ea_remove_stuffed(ip, &el); in gfs2_xattr_remove()
1136 error = ea_remove_unstuffed(ip, el.el_bh, el.el_ea, el.el_prev, 0); in gfs2_xattr_remove()
1145 * @ip: The inode
1160 struct gfs2_inode *ip = GFS2_I(inode); in __gfs2_xattr_set() local
1172 error = gfs2_xattr_remove(ip, type, name); in __gfs2_xattr_set()
1181 if (!ip->i_eattr) { in __gfs2_xattr_set()
1184 return ea_init(ip, type, name, value, size); in __gfs2_xattr_set()
1187 error = gfs2_ea_find(ip, type, name, &el); in __gfs2_xattr_set()
1192 if (ip->i_diskflags & GFS2_DIF_APPENDONLY) { in __gfs2_xattr_set()
1200 error = ea_set_i(ip, type, name, value, size, &el); in __gfs2_xattr_set()
1202 ea_set_remove_unstuffed(ip, &el); in __gfs2_xattr_set()
1211 error = ea_set_i(ip, type, name, value, size, NULL); in __gfs2_xattr_set()
1221 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_xattr_set() local
1225 ret = gfs2_qa_get(ip); in gfs2_xattr_set()
1231 if (!gfs2_glock_is_locked_by_me(ip->i_gl)) { in gfs2_xattr_set()
1232 ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); in gfs2_xattr_set()
1236 if (WARN_ON_ONCE(ip->i_gl->gl_state != LM_ST_EXCLUSIVE)) { in gfs2_xattr_set()
1246 gfs2_qa_put(ip); in gfs2_xattr_set()
1250 static int ea_dealloc_indirect(struct gfs2_inode *ip) in ea_dealloc_indirect() argument
1252 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_dealloc_indirect()
1270 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, 0, &indbh); in ea_dealloc_indirect()
1293 gfs2_rlist_add(ip, &rlist, bstart); in ea_dealloc_indirect()
1300 gfs2_rlist_add(ip, &rlist, bstart); in ea_dealloc_indirect()
1320 gfs2_trans_add_meta(ip->i_gl, indbh); in ea_dealloc_indirect()
1338 gfs2_free_meta(ip, rgd, bstart, blen); in ea_dealloc_indirect()
1345 gfs2_add_inode_blocks(&ip->i_inode, -1); in ea_dealloc_indirect()
1348 gfs2_free_meta(ip, rgd, bstart, blen); in ea_dealloc_indirect()
1350 ip->i_diskflags &= ~GFS2_DIF_EA_INDIRECT; in ea_dealloc_indirect()
1352 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_dealloc_indirect()
1354 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_dealloc_indirect()
1355 gfs2_dinode_out(ip, dibh->b_data); in ea_dealloc_indirect()
1370 static int ea_dealloc_block(struct gfs2_inode *ip) in ea_dealloc_block() argument
1372 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_dealloc_block()
1382 rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr, 1); in ea_dealloc_block()
1384 gfs2_consist_inode(ip); in ea_dealloc_block()
1397 gfs2_free_meta(ip, rgd, ip->i_eattr, 1); in ea_dealloc_block()
1399 ip->i_eattr = 0; in ea_dealloc_block()
1400 gfs2_add_inode_blocks(&ip->i_inode, -1); in ea_dealloc_block()
1402 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_dealloc_block()
1404 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_dealloc_block()
1405 gfs2_dinode_out(ip, dibh->b_data); in ea_dealloc_block()
1418 * @ip: the inode
1423 int gfs2_ea_dealloc(struct gfs2_inode *ip) in gfs2_ea_dealloc() argument
1427 error = gfs2_rindex_update(GFS2_SB(&ip->i_inode)); in gfs2_ea_dealloc()
1431 error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE); in gfs2_ea_dealloc()
1435 error = ea_foreach(ip, ea_dealloc_unstuffed, NULL); in gfs2_ea_dealloc()
1439 if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) { in gfs2_ea_dealloc()
1440 error = ea_dealloc_indirect(ip); in gfs2_ea_dealloc()
1445 error = ea_dealloc_block(ip); in gfs2_ea_dealloc()
1448 gfs2_quota_unhold(ip); in gfs2_ea_dealloc()