]> git.pld-linux.org Git - packages/parted.git/blob - 0022-dasd-enhance-device-probing.patch
- rel 4; tons of patches from FC
[packages/parted.git] / 0022-dasd-enhance-device-probing.patch
1 From 834713b5aee1edc004f863231dd489ee3a79f536 Mon Sep 17 00:00:00 2001
2 From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
3 Date: Thu, 17 Sep 2015 15:33:29 +0200
4 Subject: [PATCH 22/22] dasd: enhance device probing
5
6 Probe for all device/transport types as every block device
7 could be a DASD on s390.
8
9 Since the calculation of the minimum and optimum alignment
10 is different between DASDs and common fixed block disks
11 we need a means other than dev->type == PED_DEVICE_DASD.
12 For that purpose a static function _ped_device_like_dasd()
13 offering a DASD detection heuristic has been added to
14 arch/linux.c.
15
16 By always providing arch-specific alignment functions the
17 need for DASD-specific code could be removed from device.c.
18
19 Observe fdasd_get_geometry return code for proper error
20 handling.
21
22 Remove the obsolete API check as we no longer require the
23 DASD-specific IOCTLs.
24
25 Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
26 Acked-by: Stefan Haberland <stefan.haberland@de.ibm.com>
27 Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
28 Signed-off-by: Brian C. Lane <bcl@redhat.com>
29 ---
30  libparted/arch/linux.c  | 85 ++++++++++++++++++++++++++++++++++++++++---------
31  libparted/device.c      | 14 +++-----
32  libparted/labels/dasd.c | 18 +++++------
33  3 files changed, 82 insertions(+), 35 deletions(-)
34
35 diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
36 index adc368d..9344ceb 100644
37 --- a/libparted/arch/linux.c
38 +++ b/libparted/arch/linux.c
39 @@ -785,9 +785,13 @@ _device_set_sector_size (PedDevice* dev)
40  #endif
41  
42  #if defined __s390__ || defined __s390x__
43 +        /* The real_sector_size is currently needed for DASD layouts,
44 +         * so we set it unconditionally. In the long run it should
45 +         * be considered to use the dev->phys_sector_size in label/dasd.c.
46 +         */
47 +        arch_specific->real_sector_size = dev->sector_size;
48          /* Return PED_SECTOR_SIZE_DEFAULT for DASDs. */
49          if (dev->type == PED_DEVICE_DASD) {
50 -                arch_specific->real_sector_size = dev->sector_size;
51                  dev->sector_size = PED_SECTOR_SIZE_DEFAULT;
52          }
53  #endif
54 @@ -3167,19 +3171,72 @@ linux_disk_commit (PedDisk* disk)
55  {
56          if (disk->dev->type != PED_DEVICE_FILE) {
57  
58 -               /* We now require BLKPG support.  If this assertion fails,
59 -                  please write to the mailing list describing your system.
60 -                  Assuming it's never triggered, ...
61 -                  FIXME: remove this assertion in 2012.  */
62 -               assert (_have_blkpg ());
63 +                /* We now require BLKPG support.  If this assertion fails,
64 +                   please write to the mailing list describing your system.
65 +                   Assuming it's never triggered, ...
66 +                   FIXME: remove this assertion in 2012.  */
67 +                assert (_have_blkpg ());
68  
69 -               if (!_disk_sync_part_table (disk))
70 -                       return 0;
71 +                if (!_disk_sync_part_table (disk))
72 +                        return 0;
73          }
74  
75          return 1;
76  }
77  
78 +#if defined __s390__ || defined __s390x__
79 +/**
80 + * Check whether this device could be a DASD
81 + *
82 + * The device probing yields PED_DEVICE_DASD for native DASD transport
83 + * If the block device uses a different transport (e.g. virtio)
84 + * a simplified heuristic (assuming a model 3390 with 4K sectors)
85 + * is applied (only) on s390x systems for this check.
86 + *
87 + * \return 1 if the geometry indicates this could be a DASD
88 + *         and 0 otherwise
89 + */
90 +static int
91 +_ped_device_like_dasd(const PedDevice *dev)
92 +{
93 +        return (dev->type == PED_DEVICE_DASD)
94 +          || (dev->hw_geom.heads == 15
95 +              && dev->hw_geom.sectors == 12
96 +              && (dev->hw_geom.cylinders
97 +                  * dev->hw_geom.heads
98 +                  * dev->hw_geom.sectors
99 +                  * dev->phys_sector_size
100 +                  == dev->length * dev->sector_size));
101 +}
102 +
103 +
104 +
105 +static PedAlignment*
106 +s390_get_minimum_alignment(const PedDevice *dev)
107 +{
108 +#if USE_BLKID
109 +        return linux_get_minimum_alignment(dev);
110 +#else
111 +        return ped_alignment_new(0,
112 +                                 dev->phys_sector_size
113 +                                 / dev->sector_size);
114 +#endif
115 +}
116 +
117 +static PedAlignment*
118 +s390_get_optimum_alignment(const PedDevice *dev)
119 +{
120 +        /* DASD needs to use minimum alignment */
121 +        if (_ped_device_like_dasd(dev))
122 +                return s390_get_minimum_alignment(dev);
123 +#if USE_BLKID
124 +        return linux_get_optimum_alignment(dev);
125 +#else
126 +        return NULL;
127 +#endif
128 +}
129 +#endif
130 +
131  #if USE_BLKID
132  static PedAlignment*
133  linux_get_minimum_alignment(const PedDevice *dev)
134 @@ -3220,15 +3277,10 @@ linux_get_optimum_alignment(const PedDevice *dev)
135                 && PED_DEFAULT_ALIGNMENT % optimal_io == 0)
136             || (!optimal_io && minimum_io
137                 && PED_DEFAULT_ALIGNMENT % minimum_io == 0)
138 -           ) {
139 -            /* DASD needs to use minimum alignment */
140 -            if (dev->type == PED_DEVICE_DASD)
141 -                return linux_get_minimum_alignment(dev);
142 -
143 +           )
144              return ped_alignment_new(
145                      blkid_topology_get_alignment_offset(tp) / dev->sector_size,
146                      PED_DEFAULT_ALIGNMENT / dev->sector_size);
147 -        }
148  
149          /* If optimal_io_size is 0 and we don't meet the other criteria
150             for using the device.c default, return the minimum alignment. */
151 @@ -3255,7 +3307,10 @@ static PedDeviceArchOps linux_dev_ops = {
152          sync:           linux_sync,
153          sync_fast:      linux_sync_fast,
154          probe_all:      linux_probe_all,
155 -#if USE_BLKID
156 +#if defined __s390__ || defined __s390x__
157 +        get_minimum_alignment: s390_get_minimum_alignment,
158 +        get_optimum_alignment: s390_get_optimum_alignment,
159 +#elif USE_BLKID
160          get_minimum_alignment: linux_get_minimum_alignment,
161          get_optimum_alignment: linux_get_optimum_alignment,
162  #endif
163 diff --git a/libparted/device.c b/libparted/device.c
164 index cdcc117..36fecd2 100644
165 --- a/libparted/device.c
166 +++ b/libparted/device.c
167 @@ -550,16 +550,10 @@ ped_device_get_optimum_alignment(const PedDevice *dev)
168          /* If the arch specific code could not give as an alignment
169             return a default value based on the type of device. */
170          if (align == NULL) {
171 -                switch (dev->type) {
172 -                case PED_DEVICE_DASD:
173 -                        align = ped_device_get_minimum_alignment(dev);
174 -                        break;
175 -                default:
176 -                        /* Align to a grain of 1MiB (like vista / win7) */
177 -                        align = ped_alignment_new(0,
178 -                                                  (PED_DEFAULT_ALIGNMENT
179 -                                                  / dev->sector_size));
180 -                }
181 +                /* Align to a grain of 1MiB (like vista / win7) */
182 +                align = ped_alignment_new(0,
183 +                                          (PED_DEFAULT_ALIGNMENT
184 +                                           / dev->sector_size));
185          }
186  
187          return align;
188 diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
189 index fa9414f..bb32d66 100644
190 --- a/libparted/labels/dasd.c
191 +++ b/libparted/labels/dasd.c
192 @@ -214,19 +214,13 @@ dasd_probe (const PedDevice *dev)
193  
194         PED_ASSERT(dev != NULL);
195  
196 -       if (!(dev->type == PED_DEVICE_DASD
197 -              || dev->type == PED_DEVICE_VIODASD
198 -              || dev->type == PED_DEVICE_FILE))
199 -               return 0;
200 -
201         arch_specific = LINUX_SPECIFIC(dev);
202  
203         /* add partition test here */
204         fdasd_initialize_anchor(&anchor);
205  
206 -       fdasd_get_geometry(dev, &anchor, arch_specific->fd);
207 -
208 -       fdasd_check_api_version(&anchor, arch_specific->fd);
209 +       if (fdasd_get_geometry(dev, &anchor, arch_specific->fd) == 0)
210 +                goto error_cleanup;
211  
212         /* Labels are required on CDL formatted DASDs. */
213         if (fdasd_check_volume(&anchor, arch_specific->fd) &&
214 @@ -276,7 +270,9 @@ dasd_read (PedDisk* disk)
215  
216         fdasd_initialize_anchor(&anchor);
217  
218 -       fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd);
219 +       if (fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd) == 0)
220 +                goto error_close_dev;
221 +
222         disk_specific->label_block = anchor.label_block;
223  
224         if ((anchor.geo.cylinders * anchor.geo.heads) > BIG_DISK_SIZE)
225 @@ -630,7 +626,9 @@ dasd_write (const PedDisk* disk)
226  
227         /* initialize the anchor */
228         fdasd_initialize_anchor(&anchor);
229 -       fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd);
230 +       if (fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd) == 0)
231 +                goto error;
232 +
233         fdasd_check_volume(&anchor, arch_specific->fd);
234         memcpy(anchor.vlabel, &disk_specific->vlabel, sizeof(volume_label_t));
235         anchor.vlabel_changed++;
236 -- 
237 2.4.3
238
This page took 0.157189 seconds and 3 git commands to generate.