/* Returns 0 if the super was successfully pinned (or pinning wasn't needed), 1 if we failed.  */
static int pin_sb_for_writeback(struct writeback_control *wbc, struct inode *inode, struct super_block **psb)
/* Returns 0 if the super was successfully pinned (or pinning wasn't needed), 1 if we failed.  */
static int pin_sb_for_writeback(struct writeback_control *wbc, struct inode *inode, struct super_block **psb)
{
	struct super_block *sb = inode->i_sb;
	if (sb == *psb)
		return 0;
	else if (*psb)
		unpin_sb_for_writeback(psb);
	if (wbc->sync_mode == WB_SYNC_ALL) {
		WARN_ON(!rwsem_is_locked(&sb->s_umount));
		return 0;
	}
	spin_lock(&sb_lock);
	sb->s_count++;
	if (down_read_trylock(&sb->s_umount)) {
		if (sb->s_root) {
			spin_unlock(&sb_lock);
			goto pinned;
		}
		up_read(&sb->s_umount);
	}
	sb->s_count--;
	spin_unlock(&sb_lock);
	return 1;
pinned:
	*psb = sb;
	return 0;
}