For an irreversible expansion or compression, let $P_B(t)$ represent the gas pressure on the portion of its boundary where the work is being done, and let $T_B(t)$ represent represent the gas temperature on the portion of the boundary where heat transfer is taking place, with $t$ representing the time during the irreversible change. If the change is occurring irreversibly, the gas pressure P away from the boundary and the temperature $T$ away from the boundary will vary with spatial position within the gas. So we won't be able to use an equation of state, such as the ideal gas law, to calculate the pressure at the boundary because, for a given gas volume, the pressure and temperature are not even constant over the volume. In addition to this, there are extra contributions to the force per unit area at the boundary as a result of viscous stresses in the gas (that are important only in irreversible changes, where the gas is deforming rapidly). The force per unit area depends not just on the volume but also on the rate of change of volume.
For a reversible change, all these difficulties go away. The pressure and temperature of the gas are uniform throughout and viscous stresses are negligible, so the boundary pressure $P_B$ is equal to the average gas pressure, and the equation of state can be used to describe the pressure, volume, and temperature.
So, what do we do in the case of an irreversible change. Basically, for both irreversible and reversible changes, the equation for the work is the same:$$W=\int P_B\rm\; dV\;.$$ This is just the integral of the force the gas exerts on its surroundings over the distance the force is applied. But, unlike a reversible change, we can not depend on the equation of state to control the value of the boundary pressure $P_B$. So we need to control it manually from the outside, using either a pressure transducer at the boundary combined with a feedback control system on the piston movement, or, in simpler cases, by adding or removing a weight to the piston.
In the case you were describing, the initial and final temperatures of the gas were the same, so there was no change in internal energy. Therefore, the heat added in the irreversible process as equal to the work:$$Q=\int P_B\;\rm dV\;.$$ Also, because the part of the cylinder where heat transfer is occurring is in contact with a constant temperature bath, $T_B$ is equal to the bath temperature.
It is not very widely known, but the Clausius inequality calls for the use of the boundary temperature in comparing $\Delta S$ to the integral of $\rm \partial Q/T.$ In particular, $$\Delta S \geq \int \frac{\rm \partial Q}{T_B}\;.$$ So, how do you get the change in entropy for an irreversible process if you can't use this equation. You start out by forgetting all about the irreversible process and focusing only on the two end states. You then devise a reversible process between these same two end states and calculate the entropy change for that process. This will give you the entropy change for your irreversible process.