super.c (19139539207934aef6335bdef09c9e4bd70d1808) | super.c (2b95a23c4f50c42fe85f0d345612075d0f2c3118) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Simple file system for zoned block devices exposing zones as files. 4 * 5 * Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 */ 7#include <linux/module.h> 8#include <linux/pagemap.h> --- 1021 unchanged lines hidden (view full) --- 1030{ 1031 struct zonefs_inode_info *zi = ZONEFS_I(inode); 1032 struct zonefs_sb_info *sbi = ZONEFS_SB(inode->i_sb); 1033 int ret = 0; 1034 1035 mutex_lock(&zi->i_truncate_mutex); 1036 1037 if (!zi->i_wr_refcnt) { | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Simple file system for zoned block devices exposing zones as files. 4 * 5 * Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 */ 7#include <linux/module.h> 8#include <linux/pagemap.h> --- 1021 unchanged lines hidden (view full) --- 1030{ 1031 struct zonefs_inode_info *zi = ZONEFS_I(inode); 1032 struct zonefs_sb_info *sbi = ZONEFS_SB(inode->i_sb); 1033 int ret = 0; 1034 1035 mutex_lock(&zi->i_truncate_mutex); 1036 1037 if (!zi->i_wr_refcnt) { |
1038 if (atomic_inc_return(&sbi->s_open_zones) > sbi->s_max_open_zones) { 1039 atomic_dec(&sbi->s_open_zones); | 1038 unsigned int wro = atomic_inc_return(&sbi->s_wro_seq_files); 1039 1040 if (wro > sbi->s_max_wro_seq_files) { 1041 atomic_dec(&sbi->s_wro_seq_files); |
1040 ret = -EBUSY; 1041 goto unlock; 1042 } 1043 1044 if (i_size_read(inode) < zi->i_max_size) { 1045 ret = zonefs_zone_mgmt(inode, REQ_OP_ZONE_OPEN); 1046 if (ret) { | 1042 ret = -EBUSY; 1043 goto unlock; 1044 } 1045 1046 if (i_size_read(inode) < zi->i_max_size) { 1047 ret = zonefs_zone_mgmt(inode, REQ_OP_ZONE_OPEN); 1048 if (ret) { |
1047 atomic_dec(&sbi->s_open_zones); | 1049 atomic_dec(&sbi->s_wro_seq_files); |
1048 goto unlock; 1049 } 1050 zi->i_flags |= ZONEFS_ZONE_OPEN; 1051 } 1052 } 1053 1054 zi->i_wr_refcnt++; 1055 --- 47 unchanged lines hidden (view full) --- 1103 if (zi->i_flags & ZONEFS_ZONE_OPEN && 1104 !(sb->s_flags & SB_RDONLY)) { 1105 zonefs_warn(sb, "closing zone failed, remounting filesystem read-only\n"); 1106 sb->s_flags |= SB_RDONLY; 1107 } 1108 } 1109 zi->i_flags &= ~ZONEFS_ZONE_OPEN; 1110dec: | 1050 goto unlock; 1051 } 1052 zi->i_flags |= ZONEFS_ZONE_OPEN; 1053 } 1054 } 1055 1056 zi->i_wr_refcnt++; 1057 --- 47 unchanged lines hidden (view full) --- 1105 if (zi->i_flags & ZONEFS_ZONE_OPEN && 1106 !(sb->s_flags & SB_RDONLY)) { 1107 zonefs_warn(sb, "closing zone failed, remounting filesystem read-only\n"); 1108 sb->s_flags |= SB_RDONLY; 1109 } 1110 } 1111 zi->i_flags &= ~ZONEFS_ZONE_OPEN; 1112dec: |
1111 atomic_dec(&sbi->s_open_zones); | 1113 atomic_dec(&sbi->s_wro_seq_files); |
1112 } 1113 mutex_unlock(&zi->i_truncate_mutex); 1114} 1115 1116static int zonefs_file_release(struct inode *inode, struct file *file) 1117{ 1118 /* 1119 * If we explicitly open a zone we must close it again as well, but the --- 563 unchanged lines hidden (view full) --- 1683 * interface constraints. 1684 */ 1685 sb_set_blocksize(sb, bdev_zone_write_granularity(sb->s_bdev)); 1686 sbi->s_zone_sectors_shift = ilog2(bdev_zone_sectors(sb->s_bdev)); 1687 sbi->s_uid = GLOBAL_ROOT_UID; 1688 sbi->s_gid = GLOBAL_ROOT_GID; 1689 sbi->s_perm = 0640; 1690 sbi->s_mount_opts = ZONEFS_MNTOPT_ERRORS_RO; | 1114 } 1115 mutex_unlock(&zi->i_truncate_mutex); 1116} 1117 1118static int zonefs_file_release(struct inode *inode, struct file *file) 1119{ 1120 /* 1121 * If we explicitly open a zone we must close it again as well, but the --- 563 unchanged lines hidden (view full) --- 1685 * interface constraints. 1686 */ 1687 sb_set_blocksize(sb, bdev_zone_write_granularity(sb->s_bdev)); 1688 sbi->s_zone_sectors_shift = ilog2(bdev_zone_sectors(sb->s_bdev)); 1689 sbi->s_uid = GLOBAL_ROOT_UID; 1690 sbi->s_gid = GLOBAL_ROOT_GID; 1691 sbi->s_perm = 0640; 1692 sbi->s_mount_opts = ZONEFS_MNTOPT_ERRORS_RO; |
1691 sbi->s_max_open_zones = bdev_max_open_zones(sb->s_bdev); 1692 atomic_set(&sbi->s_open_zones, 0); 1693 if (!sbi->s_max_open_zones && | 1693 1694 atomic_set(&sbi->s_wro_seq_files, 0); 1695 sbi->s_max_wro_seq_files = bdev_max_open_zones(sb->s_bdev); 1696 if (!sbi->s_max_wro_seq_files && |
1694 sbi->s_mount_opts & ZONEFS_MNTOPT_EXPLICIT_OPEN) { 1695 zonefs_info(sb, "No open zones limit. Ignoring explicit_open mount option\n"); 1696 sbi->s_mount_opts &= ~ZONEFS_MNTOPT_EXPLICIT_OPEN; 1697 } 1698 1699 ret = zonefs_read_super(sb); 1700 if (ret) 1701 return ret; --- 123 unchanged lines hidden --- | 1697 sbi->s_mount_opts & ZONEFS_MNTOPT_EXPLICIT_OPEN) { 1698 zonefs_info(sb, "No open zones limit. Ignoring explicit_open mount option\n"); 1699 sbi->s_mount_opts &= ~ZONEFS_MNTOPT_EXPLICIT_OPEN; 1700 } 1701 1702 ret = zonefs_read_super(sb); 1703 if (ret) 1704 return ret; --- 123 unchanged lines hidden --- |