• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/fs/gfs2/

Lines Matching refs:ip

38 typedef int (*block_call_t) (struct gfs2_inode *ip, struct buffer_head *dibh,
50 * @ip: the inode
58 static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
61 struct inode *inode = &ip->i_inode;
96 if (!gfs2_is_jdata(ip))
98 if (!gfs2_is_writeback(ip))
99 gfs2_trans_add_bh(ip->i_gl, bh, 0);
111 * @ip: The GFS2 inode to unstuff
121 int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
126 int isdir = gfs2_is_dir(ip);
129 down_write(&ip->i_rw_mutex);
131 error = gfs2_meta_inode_buffer(ip, &dibh);
135 if (ip->i_disksize) {
140 error = gfs2_alloc_block(ip, &block, &n);
144 gfs2_trans_add_unrevoke(GFS2_SB(&ip->i_inode), block, 1);
145 error = gfs2_dir_get_new_buffer(ip, block, &bh);
152 error = gfs2_unstuffer_page(ip, dibh, block, page);
160 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
164 if (ip->i_disksize) {
166 gfs2_add_inode_blocks(&ip->i_inode, 1);
167 di->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode));
170 ip->i_height = 1;
176 up_write(&ip->i_rw_mutex);
189 * through the metadata of inode "ip" to get to block "block".
192 * Given: "ip" is a height 3 file, "offset" is 101342453, and this is a
278 * @ip: The inode
293 static int lookup_metapath(struct gfs2_inode *ip, struct metapath *mp)
295 unsigned int end_of_metadata = ip->i_height - 1;
307 ret = gfs2_meta_indirect_buffer(ip, x+1, dblock, 0, &mp->mp_bh[x+1]);
312 return ip->i_height;
362 static inline void bmap_lock(struct gfs2_inode *ip, int create)
365 down_write(&ip->i_rw_mutex);
367 down_read(&ip->i_rw_mutex);
370 static inline void bmap_unlock(struct gfs2_inode *ip, int create)
373 up_write(&ip->i_rw_mutex);
375 up_read(&ip->i_rw_mutex);
433 struct gfs2_inode *ip = GFS2_I(inode);
449 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
464 if (height == ip->i_height) {
471 iblks = height - ip->i_height;
484 error = gfs2_alloc_block(ip, &bn, &n);
488 if (state != ALLOC_DATA || gfs2_is_jdata(ip))
498 for (; i - 1 < height - ip->i_height && n > 0; i++, n--)
499 gfs2_indirect_init(mp, ip->i_gl, i, 0, bn++);
500 if (i - 1 == height - ip->i_height) {
525 gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[i-1], 1);
527 gfs2_indirect_init(mp, ip->i_gl, i,
537 gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[end_of_metadata], 1);
547 ip->i_height = height;
548 gfs2_add_inode_blocks(&ip->i_inode, alloced);
549 gfs2_dinode_out(ip, mp->mp_bh[0]->b_data);
573 struct gfs2_inode *ip = GFS2_I(inode);
590 bmap_lock(ip, create);
594 trace_gfs2_bmap(ip, bh_map, lblock, create, 1);
595 if (gfs2_is_dir(ip)) {
600 ret = gfs2_meta_inode_buffer(ip, &mp.mp_bh[0]);
604 height = ip->i_height;
610 if (height > ip->i_height || gfs2_is_stuffed(ip))
612 ret = lookup_metapath(ip, &mp);
615 if (ret != ip->i_height)
617 ptr = metapointer(ip->i_height - 1, &mp);
621 bh = mp.mp_bh[ip->i_height - 1];
629 trace_gfs2_bmap(ip, bh_map, lblock, create, ret);
630 bmap_unlock(ip, create);
636 BUG_ON(gfs2_is_stuffed(ip));
672 * @ip: the inode
687 static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh,
692 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
700 error = gfs2_meta_inode_buffer(ip, &bh);
708 error = gfs2_meta_indirect_buffer(ip, height, block, 0, &bh);
718 error = bc(ip, dibh, bh, top, bottom, height, data);
722 if (height < ip->i_height - 1)
729 error = recursive_scan(ip, dibh, mp, height + 1, bn,
742 * @ip: the inode
753 static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
758 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
780 metadata = (height != ip->i_height - 1);
784 error = gfs2_rindex_hold(sdp, &ip->i_alloc->al_ri_gh);
832 down_write(&ip->i_rw_mutex);
834 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
835 gfs2_trans_add_bh(ip->i_gl, bh, 1);
851 gfs2_free_meta(ip, bstart, blen);
853 gfs2_free_data(ip, bstart, blen);
861 gfs2_add_inode_blocks(&ip->i_inode, -1);
865 gfs2_free_meta(ip, bstart, blen);
867 gfs2_free_data(ip, bstart, blen);
870 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
872 gfs2_dinode_out(ip, dibh->b_data);
874 up_write(&ip->i_rw_mutex);
883 gfs2_glock_dq_uninit(&ip->i_alloc->al_ri_gh);
889 * @ip: the inode
892 * Called with an exclusive lock on @ip.
897 static int do_grow(struct gfs2_inode *ip, u64 size)
899 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
904 al = gfs2_alloc_get(ip);
908 error = gfs2_quota_lock_check(ip);
914 error = gfs2_inplace_reserve(ip);
924 error = gfs2_meta_inode_buffer(ip, &dibh);
929 if (gfs2_is_stuffed(ip)) {
930 error = gfs2_unstuff_dinode(ip, NULL);
936 ip->i_disksize = size;
937 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
938 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
939 gfs2_dinode_out(ip, dibh->b_data);
946 gfs2_inplace_release(ip);
948 gfs2_quota_unlock(ip);
950 gfs2_alloc_put(ip);
963 struct gfs2_inode *ip = GFS2_I(inode);
1015 if (!gfs2_is_writeback(ip))
1016 gfs2_trans_add_bh(ip->i_gl, bh, 0);
1026 static int trunc_start(struct gfs2_inode *ip, u64 size)
1028 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1030 int journaled = gfs2_is_jdata(ip);
1038 error = gfs2_meta_inode_buffer(ip, &dibh);
1042 if (gfs2_is_stuffed(ip)) {
1044 ip->i_disksize = size;
1045 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
1046 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1047 gfs2_dinode_out(ip, dibh->b_data);
1054 error = gfs2_block_truncate_page(ip->i_inode.i_mapping);
1057 ip->i_disksize = size;
1058 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
1059 ip->i_diskflags |= GFS2_DIF_TRUNC_IN_PROG;
1060 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1061 gfs2_dinode_out(ip, dibh->b_data);
1072 static int trunc_dealloc(struct gfs2_inode *ip, u64 size)
1074 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1075 unsigned int height = ip->i_height;
1085 find_metapath(sdp, lblock, &mp, ip->i_height);
1086 if (!gfs2_alloc_get(ip))
1089 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
1098 error = recursive_scan(ip, NULL, &mp, 0, 0, 1, do_strip, &sm);
1103 gfs2_quota_unhold(ip);
1106 gfs2_alloc_put(ip);
1110 static int trunc_end(struct gfs2_inode *ip)
1112 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1120 down_write(&ip->i_rw_mutex);
1122 error = gfs2_meta_inode_buffer(ip, &dibh);
1126 if (!ip->i_disksize) {
1127 ip->i_height = 0;
1128 ip->i_goal = ip->i_no_addr;
1131 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
1132 ip->i_diskflags &= ~GFS2_DIF_TRUNC_IN_PROG;
1134 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1135 gfs2_dinode_out(ip, dibh->b_data);
1139 up_write(&ip->i_rw_mutex);
1146 * @ip: the inode
1150 * Called with an exclusive lock on @ip.
1155 static int do_shrink(struct gfs2_inode *ip, u64 size)
1159 error = trunc_start(ip, size);
1165 error = trunc_dealloc(ip, size);
1167 error = trunc_end(ip);
1172 static int do_touch(struct gfs2_inode *ip, u64 size)
1174 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1182 down_write(&ip->i_rw_mutex);
1184 error = gfs2_meta_inode_buffer(ip, &dibh);
1188 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
1189 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1190 gfs2_dinode_out(ip, dibh->b_data);
1194 up_write(&ip->i_rw_mutex);
1201 * @ip: the inode
1210 int gfs2_truncatei(struct gfs2_inode *ip, u64 size)
1214 if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), S_ISREG(ip->i_inode.i_mode)))
1217 if (size > ip->i_disksize)
1218 error = do_grow(ip, size);
1219 else if (size < ip->i_disksize)
1220 error = do_shrink(ip, size);
1223 error = do_touch(ip, size);
1228 int gfs2_truncatei_resume(struct gfs2_inode *ip)
1231 error = trunc_dealloc(ip, ip->i_disksize);
1233 error = trunc_end(ip);
1237 int gfs2_file_dealloc(struct gfs2_inode *ip)
1239 return trunc_dealloc(ip, 0);
1244 * @ip: the file being written to
1251 int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
1254 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1263 if (gfs2_is_stuffed(ip)) {
1271 BUG_ON(gfs2_is_dir(ip));
1272 end_of_file = (ip->i_disksize + sdp->sd_sb.sb_bsize - 1) >> shift;
1282 gfs2_block_map(&ip->i_inode, lblock, &bh, 0);
1286 lblock += (bh.b_size >> ip->i_inode.i_blkbits);