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()
594 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_xattr_get() local
600 if (!gfs2_glock_is_locked_by_me(ip->i_gl)) { in gfs2_xattr_get()
601 ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); in gfs2_xattr_get()
615 * @ip: A pointer to the inode that's getting extended attributes
621 static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp) in ea_alloc_blk() argument
623 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_alloc_blk()
629 error = gfs2_alloc_blocks(ip, &block, &n, 0, NULL); in ea_alloc_blk()
633 *bhp = gfs2_meta_new(ip->i_gl, block); in ea_alloc_blk()
634 gfs2_trans_add_meta(ip->i_gl, *bhp); in ea_alloc_blk()
644 gfs2_add_inode_blocks(&ip->i_inode, 1); in ea_alloc_blk()
652 * @ip: inode that is being modified
661 static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea, in ea_write() argument
664 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_write()
691 error = gfs2_alloc_blocks(ip, &block, &n, 0, NULL); in ea_write()
695 bh = gfs2_meta_new(ip->i_gl, block); in ea_write()
696 gfs2_trans_add_meta(ip->i_gl, bh); in ea_write()
699 gfs2_add_inode_blocks(&ip->i_inode, 1); in ea_write()
721 typedef int (*ea_skeleton_call_t) (struct gfs2_inode *ip,
724 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 ip->i_inode.i_ctime = current_time(&ip->i_inode); in ea_alloc_skeleton()
754 __mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC); in ea_alloc_skeleton()
757 gfs2_trans_end(GFS2_SB(&ip->i_inode)); in ea_alloc_skeleton()
759 gfs2_inplace_release(ip); in ea_alloc_skeleton()
761 gfs2_quota_unlock(ip); in ea_alloc_skeleton()
765 static int ea_init_i(struct gfs2_inode *ip, struct gfs2_ea_request *er, in ea_init_i() argument
771 error = ea_alloc_blk(ip, &bh); in ea_init_i()
775 ip->i_eattr = bh->b_blocknr; in ea_init_i()
776 error = ea_write(ip, GFS2_EA_BH2FIRST(bh), er); in ea_init_i()
785 * @ip:
791 static int ea_init(struct gfs2_inode *ip, int type, const char *name, in ea_init() argument
795 unsigned int jbsize = GFS2_SB(&ip->i_inode)->sd_jbsize; in ea_init()
807 return ea_alloc_skeleton(ip, &er, blks, ea_init_i, NULL); in ea_init()
827 static void ea_set_remove_stuffed(struct gfs2_inode *ip, in ea_set_remove_stuffed() argument
834 gfs2_trans_add_meta(ip->i_gl, el->el_bh); in ea_set_remove_stuffed()
841 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), GFS2_EA2NEXT(prev) == ea); in ea_set_remove_stuffed()
861 static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh, in ea_set_simple_noalloc() argument
867 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + 2 * RES_EATTR, 0); in ea_set_simple_noalloc()
871 gfs2_trans_add_meta(ip->i_gl, bh); in ea_set_simple_noalloc()
876 ea_write(ip, ea, er); in ea_set_simple_noalloc()
879 ea_set_remove_stuffed(ip, es->es_el); in ea_set_simple_noalloc()
881 ip->i_inode.i_ctime = current_time(&ip->i_inode); in ea_set_simple_noalloc()
882 __mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC); in ea_set_simple_noalloc()
884 gfs2_trans_end(GFS2_SB(&ip->i_inode)); in ea_set_simple_noalloc()
888 static int ea_set_simple_alloc(struct gfs2_inode *ip, in ea_set_simple_alloc() argument
895 gfs2_trans_add_meta(ip->i_gl, es->es_bh); in ea_set_simple_alloc()
900 error = ea_write(ip, ea, er); in ea_set_simple_alloc()
905 ea_set_remove_stuffed(ip, es->es_el); in ea_set_simple_alloc()
910 static int ea_set_simple(struct gfs2_inode *ip, struct buffer_head *bh, in ea_set_simple() argument
919 stuffed = ea_calc_size(GFS2_SB(&ip->i_inode), es->es_er->er_name_len, in ea_set_simple()
926 error = ea_remove_unstuffed(ip, bh, ea, prev, 1); in ea_set_simple()
937 error = ea_set_simple_noalloc(ip, bh, ea, es); in ea_set_simple()
946 GFS2_SB(&ip->i_inode)->sd_jbsize); in ea_set_simple()
948 error = ea_alloc_skeleton(ip, es->es_er, blks, in ea_set_simple()
957 static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er, in ea_set_block() argument
960 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_set_block()
966 if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) { in ea_set_block()
969 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, 0, in ea_set_block()
991 gfs2_trans_add_meta(ip->i_gl, indbh); in ea_set_block()
995 error = gfs2_alloc_blocks(ip, &blk, &n, 0, NULL); in ea_set_block()
999 indbh = gfs2_meta_new(ip->i_gl, blk); in ea_set_block()
1000 gfs2_trans_add_meta(ip->i_gl, indbh); in ea_set_block()
1005 *eablk = cpu_to_be64(ip->i_eattr); in ea_set_block()
1006 ip->i_eattr = blk; in ea_set_block()
1007 ip->i_diskflags |= GFS2_DIF_EA_INDIRECT; in ea_set_block()
1008 gfs2_add_inode_blocks(&ip->i_inode, 1); in ea_set_block()
1013 error = ea_alloc_blk(ip, &newbh); in ea_set_block()
1018 error = ea_write(ip, GFS2_EA_BH2FIRST(newbh), er); in ea_set_block()
1024 ea_set_remove_stuffed(ip, private); in ea_set_block()
1031 static int ea_set_i(struct gfs2_inode *ip, int type, const char *name, in ea_set_i() argument
1049 error = ea_foreach(ip, ea_set_simple, &es); in ea_set_i()
1055 if (!(ip->i_diskflags & GFS2_DIF_EA_INDIRECT)) in ea_set_i()
1057 if (GFS2_EAREQ_SIZE_STUFFED(&er) > GFS2_SB(&ip->i_inode)->sd_jbsize) in ea_set_i()
1058 blks += DIV_ROUND_UP(er.er_data_len, GFS2_SB(&ip->i_inode)->sd_jbsize); in ea_set_i()
1060 return ea_alloc_skeleton(ip, &er, blks, ea_set_block, el); in ea_set_i()
1063 static int ea_set_remove_unstuffed(struct gfs2_inode *ip, in ea_set_remove_unstuffed() argument
1068 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), in ea_set_remove_unstuffed()
1072 return ea_remove_unstuffed(ip, el->el_bh, el->el_ea, el->el_prev, 0); in ea_set_remove_unstuffed()
1075 static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el) in ea_remove_stuffed() argument
1081 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + RES_EATTR, 0); in ea_remove_stuffed()
1085 gfs2_trans_add_meta(ip->i_gl, el->el_bh); in ea_remove_stuffed()
1099 ip->i_inode.i_ctime = current_time(&ip->i_inode); in ea_remove_stuffed()
1100 __mark_inode_dirty(&ip->i_inode, I_DIRTY_DATASYNC); in ea_remove_stuffed()
1102 gfs2_trans_end(GFS2_SB(&ip->i_inode)); in ea_remove_stuffed()
1109 * @ip: The inode
1120 static int gfs2_xattr_remove(struct gfs2_inode *ip, int type, const char *name) in gfs2_xattr_remove() argument
1125 if (!ip->i_eattr) in gfs2_xattr_remove()
1128 error = gfs2_ea_find(ip, type, name, &el); in gfs2_xattr_remove()
1135 error = ea_remove_stuffed(ip, &el); in gfs2_xattr_remove()
1137 error = ea_remove_unstuffed(ip, el.el_bh, el.el_ea, el.el_prev, 0); in gfs2_xattr_remove()
1146 * @ip: The inode
1161 struct gfs2_inode *ip = GFS2_I(inode); in __gfs2_xattr_set() local
1173 error = gfs2_xattr_remove(ip, type, name); in __gfs2_xattr_set()
1182 if (!ip->i_eattr) { in __gfs2_xattr_set()
1185 return ea_init(ip, type, name, value, size); in __gfs2_xattr_set()
1188 error = gfs2_ea_find(ip, type, name, &el); in __gfs2_xattr_set()
1193 if (ip->i_diskflags & GFS2_DIF_APPENDONLY) { in __gfs2_xattr_set()
1201 error = ea_set_i(ip, type, name, value, size, &el); in __gfs2_xattr_set()
1203 ea_set_remove_unstuffed(ip, &el); in __gfs2_xattr_set()
1212 error = ea_set_i(ip, type, name, value, size, NULL); in __gfs2_xattr_set()
1222 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_xattr_set() local
1226 ret = gfs2_qa_get(ip); in gfs2_xattr_set()
1232 if (!gfs2_glock_is_locked_by_me(ip->i_gl)) { in gfs2_xattr_set()
1233 ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); in gfs2_xattr_set()
1237 if (WARN_ON_ONCE(ip->i_gl->gl_state != LM_ST_EXCLUSIVE)) { in gfs2_xattr_set()
1247 gfs2_qa_put(ip); in gfs2_xattr_set()
1251 static int ea_dealloc_indirect(struct gfs2_inode *ip) in ea_dealloc_indirect() argument
1253 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_dealloc_indirect()
1271 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, 0, &indbh); in ea_dealloc_indirect()
1294 gfs2_rlist_add(ip, &rlist, bstart); in ea_dealloc_indirect()
1301 gfs2_rlist_add(ip, &rlist, bstart); in ea_dealloc_indirect()
1321 gfs2_trans_add_meta(ip->i_gl, indbh); in ea_dealloc_indirect()
1339 gfs2_free_meta(ip, rgd, bstart, blen); in ea_dealloc_indirect()
1346 gfs2_add_inode_blocks(&ip->i_inode, -1); in ea_dealloc_indirect()
1349 gfs2_free_meta(ip, rgd, bstart, blen); in ea_dealloc_indirect()
1351 ip->i_diskflags &= ~GFS2_DIF_EA_INDIRECT; in ea_dealloc_indirect()
1353 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_dealloc_indirect()
1355 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_dealloc_indirect()
1356 gfs2_dinode_out(ip, dibh->b_data); in ea_dealloc_indirect()
1371 static int ea_dealloc_block(struct gfs2_inode *ip) in ea_dealloc_block() argument
1373 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in ea_dealloc_block()
1383 rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr, 1); in ea_dealloc_block()
1385 gfs2_consist_inode(ip); in ea_dealloc_block()
1398 gfs2_free_meta(ip, rgd, ip->i_eattr, 1); in ea_dealloc_block()
1400 ip->i_eattr = 0; in ea_dealloc_block()
1401 gfs2_add_inode_blocks(&ip->i_inode, -1); in ea_dealloc_block()
1403 error = gfs2_meta_inode_buffer(ip, &dibh); in ea_dealloc_block()
1405 gfs2_trans_add_meta(ip->i_gl, dibh); in ea_dealloc_block()
1406 gfs2_dinode_out(ip, dibh->b_data); in ea_dealloc_block()
1419 * @ip: the inode
1424 int gfs2_ea_dealloc(struct gfs2_inode *ip) in gfs2_ea_dealloc() argument
1428 error = gfs2_rindex_update(GFS2_SB(&ip->i_inode)); in gfs2_ea_dealloc()
1432 error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE); in gfs2_ea_dealloc()
1436 error = ea_foreach(ip, ea_dealloc_unstuffed, NULL); in gfs2_ea_dealloc()
1440 if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) { in gfs2_ea_dealloc()
1441 error = ea_dealloc_indirect(ip); in gfs2_ea_dealloc()
1446 error = ea_dealloc_block(ip); in gfs2_ea_dealloc()
1449 gfs2_quota_unhold(ip); in gfs2_ea_dealloc()