<commit_before>/*
 *  linux/fs/sysv/inode.c
 *
 *  minix/inode.c
 *  Copyright (C) 1991, 1992  <NAME>
 *
 *  xenix/inode.c
 *  Copyright (C) 1992  <NAME>
 *
 *  coh/inode.c
 *  Copyright (C) 1993  <NAME>, <NAME>
 *
 *  sysv/inode.c
 *  Copyright (C) 1993  <NAME>
 *
 *  sysv/inode.c
 *  Copyright (C) 1993  <NAME>
 *  Copyright (C) 1997, 1998  <NAME>
 *
 *  This file contains code for allocating/freeing inodes and for read/writing
 *  the superblock.
 */

#include <linux/highuid.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/buffer_head.h>
#include <linux/vfs.h>
#include <linux/writeback.h>
#include <linux/namei.h>
#include <asm/byteorder.h>
#include "sysv.h"

static int sysv_sync_fs(struct super_block *sb, int wait)
{
	struct sysv_sb_info *sbi = SYSV_SB(sb);
	unsigned long time = get_seconds(), old_time;

	lock_super(sb);

	/*
	 * If we are going to write out the super block,
	 * then attach current time stamp.
	 * But if the filesystem was marked clean, keep it clean.
	 */
	sb->s_dirt = 0;
	old_time = fs32_to_cpu(sbi, *sbi->s_sb_time);
	if (sbi->s_type == FSTYPE_SYSV4) {
		if (*sbi->s_sb_state == cpu_to_fs32(sbi, 0x7c269d38 - old_time))
			*sbi->s_sb_state = cpu_to_fs32(sbi, 0x7c269d38 - time);
		*sbi->s_sb_time = cpu_to_fs32(sbi, time);
		mark_buffer_dirty(sbi->s_bh2);
	}

	unlock_super(sb);

	return 0;
}

static void sysv_write_super(struct super_block *sb)
{
	if (!(sb->s_flags & MS_RDONLY))
		sysv_sync_fs(sb, 1);
	else
		sb->s_dirt = 0;
}

static int sysv_remount(struct super_block *sb, int *flags, char *data)
{
	struct sysv_sb_info *sbi = SYSV_SB(sb);
	lock_super(sb);
	if (sbi->s_forced_ro)
		*flags |= MS_RDONLY;
	if (*flags & MS_RDONLY)
		sysv_write_super(sb);
	unlock_super(sb);
	return 0;
}

static void sysv_put_super(struct super_block *sb)
{
	struct sysv_sb_info *sbi = SYSV_SB(sb);

	if (sb->s_dirt)
		sysv_write_super(sb);

	if (!(sb->s_flags & MS_RDONLY)) {
		/* XXX ext2 also updates the state here */
		mark_buffer_dirty(sbi->s_bh1);
		if (sbi->s_bh1 != sbi->s_bh2)
			mark_buffer_dirty(sbi->s_bh2);
	}

	brelse(sbi->s_bh1);
	if (sbi->s_bh1 != sbi->s_bh2)
		brelse(sbi->s_bh2);

	kfree(sbi);
}<commit_msg>fs/sysv: remove useless write_super call<commit_after>/*
 *  linux/fs/sysv/inode.c
 *
 *  minix/inode.c
 *  Copyright (C) 1991, 1992  <NAME>
 *
 *  xenix/inode.c
 *  Copyright (C) 1992  <NAME>
 *
 *  coh/inode.c
 *  Copyright (C) 1993  <NAME>, <NAME>
 *
 *  sysv/inode.c
 *  Copyright (C) 1993  <NAME>
 *
 *  sysv/inode.c
 *  Copyright (C) 1993  <NAME>
 *  Copyright (C) 1997, 1998  <NAME>
 *
 *  This file contains code for allocating/freeing inodes and for read/writing
 *  the superblock.
 */

#include <linux/highuid.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/buffer_head.h>
#include <linux/vfs.h>
#include <linux/writeback.h>
#include <linux/namei.h>
#include <asm/byteorder.h>
#include "sysv.h"

static int sysv_sync_fs(struct super_block *sb, int wait)
{
	struct sysv_sb_info *sbi = SYSV_SB(sb);
	unsigned long time = get_seconds(), old_time;

	lock_super(sb);

	/*
	 * If we are going to write out the super block,
	 * then attach current time stamp.
	 * But if the filesystem was marked clean, keep it clean.
	 */
	sb->s_dirt = 0;
	old_time = fs32_to_cpu(sbi, *sbi->s_sb_time);
	if (sbi->s_type == FSTYPE_SYSV4) {
		if (*sbi->s_sb_state == cpu_to_fs32(sbi, 0x7c269d38 - old_time))
			*sbi->s_sb_state = cpu_to_fs32(sbi, 0x7c269d38 - time);
		*sbi->s_sb_time = cpu_to_fs32(sbi, time);
		mark_buffer_dirty(sbi->s_bh2);
	}

	unlock_super(sb);

	return 0;
}

static void sysv_write_super(struct super_block *sb)
{
	if (!(sb->s_flags & MS_RDONLY))
		sysv_sync_fs(sb, 1);
	else
		sb->s_dirt = 0;
}

static int sysv_remount(struct super_block *sb, int *flags, char *data)
{
	struct sysv_sb_info *sbi = SYSV_SB(sb);
	lock_super(sb);
	if (sbi->s_forced_ro)
		*flags |= MS_RDONLY;
	if (*flags & MS_RDONLY)
		sysv_write_super(sb);
	unlock_super(sb);
	return 0;
}

static void sysv_put_super(struct super_block *sb)
{
	struct sysv_sb_info *sbi = SYSV_SB(sb);

	if (!(sb->s_flags & MS_RDONLY)) {
		/* XXX ext2 also updates the state here */
		mark_buffer_dirty(sbi->s_bh1);
		if (sbi->s_bh1 != sbi->s_bh2)
			mark_buffer_dirty(sbi->s_bh2);
	}

	brelse(sbi->s_bh1);
	if (sbi->s_bh1 != sbi->s_bh2)
		brelse(sbi->s_bh2);

	kfree(sbi);
}
{'fraction_non_alphanumeric': 0.15204813700532285, 'fraction_numerical': 0.03239990742883592, 'mean_word_length': 3.9225512528473803, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 72, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6109417', 'n_tokens_mistral': 2011, 'n_tokens_neox': 1899, 'n_words': 403}