/* Returns: 0 on successful update, error code otherwise  */
static int gfs2_ri_update(struct gfs2_inode *ip)
/* Returns: 0 on successful update, error code otherwise  */
static int gfs2_ri_update(struct gfs2_inode *ip)
{
	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
	struct inode *inode = &ip->i_inode;
	struct file_ra_state ra_state;
	u64 rgrp_count = ip->i_disksize;
	int error;
	do_div(rgrp_count, sizeof(struct gfs2_rindex));
	clear_rgrpdi(sdp);
	file_ra_state_init(&ra_state, inode->i_mapping);
	for (sdp->sd_rgrps = 0; sdp->sd_rgrps < rgrp_count; sdp->sd_rgrps++) {
		error = read_rindex_entry(ip, &ra_state);
		if (error) {
			clear_rgrpdi(sdp);
			return error;
		}
	}
	sdp->sd_rindex_uptodate = 1;
	return 0;
}